Friday, June 1, 2012

Reading a column from a Sharepoint list element

Even the title is rather complicated... Solving this took quite some time. Extracting one field (=column) of a specific list element in Sharepoint is what I need to do. This should be done to use the information in another application. I checked online but couldn't find the best way of doing it. One promising way seems to use an XML View of the list - this can easily be exportet.

This is how you create it - and call it from your browser:

http://{0}/_vti_bin/owssvr.dll?Cmd=Display&List={1}&XMLDATA=TRUE
{0} – The URL to your site.  This could be the root web or a child site.
{1} – The GUID for your list.

Example:

  • GUID for my list: {F24D7439-1A5F-41E1-9E0D-2BD39151C33F}
  • http://sharepoint/MyList/_vti_bin/owssvr.dll?Cmd=Display&List=%7bF24D7439-1A5F-41E1-9E0D-2BD39151C33F%7d&XMLDATA=TRUE
You may want to limit the number of results using a custom view:
  • GUID for my specific view: {968A1E8C-25E6-4801-93D9-412E85B3ABFE}
  • http://sharepoint/MyList /_vti_bin/owssvr.dll?Cmd=Display&List=%7bF24D7439-1A5F-41E1-9E0D-2BD39151C33F%7d&View=%7b968A1E8C-25E6-4801-93D9-412E85B3ABFE%7d&XMLDATA=TRUE

There are many different ways of achieving this. An alternative is the business connectivity Services: http://msdn.microsoft.com/de-de/library/ee557658.aspx

or reading directly from the SQL database: http://www.codeproject.com/Articles/14232/Useful-SQL-Queries-to-Analyze-and-Monitor-SharePoi

This should be done with caution - and only if it is at all necessary (reasons: performance, licence violation, instable primary key).

EDIT: this is another way of achieving what I was looking for: http://msdn.microsoft.com/de-de/library/ff521580.aspx
The MSDN article descirbes how you read a value of a field in a Sharepoint list using C#.

No comments: