Another way to retrieve SharePoint List Data - Use built in functionality!

by Oscar 10. December 2007 21:24

<UPDATE> My fellow MVP Ton Stegeman has a nice post on yet another way to use the owssvr.dll Export user information to Excel using "Export to spreadsheet" in SharePoint 2007.  He was nice enough to actually create a Feature!
</UPDATE>

Sometimes you just don't want to write your own Web Service .  You could use the built in Web Services, but you can't deploy assemblies to the MOSS server.

So what is one to do?

You can use some neat built in functionality!

Basically you can call the owssvr.dll with specific parameters such as

http://moss.litwareinc.com/_vti_bin/owssvr.dll?Cmd=Display&List={A07519C4-9605-48AA-B0B4-0FFA9E4F0CB1}&XMLDATA=TRUE

When I type this on my browser address bar, I will get a result similar to the one below

clip_image001



At this point, you can use XSL to transform the XML such as in a DataViewWebPart in the SharePoint Designer :)

Filtering results 

What if you need data that meets a specific criteria?

You can add the following parameters FilterField1 and FilterValue1

Say I want to retrieve only the Project Deliverables that have the Stage Column value set to "Delivery", you can filter like so
http://moss.litwareinc.com/_vti_bin/owssvr.dll?Cmd=Display&List={A07519C4-9605-48AA-B0B4-0FFA9E4F0CB1}&XMLDATA=TRUE&FilterField1=Project_x0020_Stage&FilterValue1=Delivery

Your results would look like this

clip_image001[5]


There is a lot more you can do, you can even update a View by changing the Cmd=Display to Cmd=UpdateView

Enjoy!

Oscar

Tags:

Calculated Columns - Displaying Images

by Oscar 2. December 2007 03:51

Recently, I was working on a project that required the  creation of an IT Project Management Site Template.  I thought, hmm, pretty straight forward, but wait, I ran into an issue that I am positive, could have been solved in other ways (List Event Handler)

The requirement was to display an image based on a certain condition, and this condition had to do with lookup of other List Column values. 

If you want to display images for a calculated column here are the steps you need to take:

  1. Modify the FLDTYPES.XML file(or make a copy of it!)
  2. Search for the field definition "Calculated"
  3. On the default rendering pattern, paste the following

    <Switch>
    <Expr>
    <GetFileExtension><Column/></GetFileExtension>
    </Expr>
    <Case Value="giF">
    <HTML><![CDATA[<IMG SRC="]]></HTML><Column HTMLEncode="TRUE"/><HTML>"</HTML>
    </Case>
    <Default>
    <Column HTMLEncode="TRUE" AutoHyperLink="TRUE"
    AutoNewLine="TRUE"/>
    </Default>
    </Switch>

    Create a new Column of type Calculated - put some logic in it like so

    =IF(AND(Impact="3",Probability="1"),"/_layouts/images/KPIDefault-1.giF",
    IF(AND(Impact="3",Probability="2"),"/_layouts/images/KPIDefault-2.giF",
    IF(AND(Impact="3",Probability="3"),"/_layouts/images/KPIDefault-2.giF",
    IF(AND(Impact="2",Probability="1"),"/_layouts/images/KPIDefault-1.giF",
    IF(AND(Impact="2",Probability="2"),"/_layouts/images/KPIDefault-1.giF",
    IF(AND(Impact="2",Probability="3"),"/_layouts/images/KPIDefault-2.giF",
    IF(AND(Impact="1",Probability="1"),"/_layouts/images/KPIDefault-0.giF",
    IF(AND(Impact="1",Probability="2"),"/_layouts/images/KPIDefault-0.giF",
    IF(AND(Impact="1",Probability="3"),"/_layouts/images/KPIDefault-1.giF","other")))))))))

    NOTE: The Impact and Probability are columns in the SharePoint List.  Based on this logic, I am re-using the images from the KPIs in MOSS and simply pointing to them.

    And that's it!   You now can output images for your List.  Here is how it looks

    image

Tags:

Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen

About Oscar

Oscar Medina - SharePoint Solutions Architect

I am a SharePoint Solutions Architect and Managing Partner at SharePointAce Consulting Group, LLC.  I have over 13 years of software development experience. 

Previously a Consultant at Microsoft Consulting Services (MCS) North West Region with focus on the SharePoint Products and Technologies Platform.  I have been involved with SharePoint since it's first version (SharePoint 2001) and have grown more gray hair providing solutions ever since :)

Author of the CQWP – Recurring Calendar Events at http://cqwprce.codeplex.com

 

Follow SharePointAce on Twitter! Follow me on Twitter.


Contributor to the book:

 

Occasional Speaker at SharePoint Saturday - SharePoint Saturday

RecentComments

Comment RSS