Tuesday 15 January 2008

MOSS - Getting items in a particular subfolder of a Picture Library via Sharepoint Web Service

[UPDATE 2007/01/16] - While this is a bug that Picture Libraries don't work properly within the normal Document Library web services, I believe that the Imaging Web service should be used for picture libraries rather the normal lists.asmx i.e.
http://[server]/[site]/_vti_bin/imaging.asmx.

An excellent chapter on this web service can be found in Sams Microsoft SharePoint 2007 Development Unleashed
[/UPDATE 2007/01/16]

It appears that you cannot filter a Picture Library by Folders using the QueryOptions parameter for .GetListItems(). I consider this to be a bug in the MOSS Web Service querying engine.

You can download a very handy tool from here to demonstrate the issue easily http://www.u2u.info/Blogs/karine/Lists/Posts/Post.aspx?List=d35935e0%2D8c0e%2D4176%2Da7e8%2D2ee90b3c8e5a&ID=12


To reproduce the bug:

  1. Make a photo library with 2 subfolders
  2. Make a normal document library with 2 subfolders
  3. Adding several photos to this photo library
  4. Adding several photos to the document library
  5. Opening up the tool, right-clicking on your list and selecting "GetItems" from the context menu
  6. Go to the View Options tab and entering your document path (e.g. MyListName/MySubfolderName)
  7. You will get the whole list from the picture library regardless of this parameter..... BUG!
  8. Try the same thing on the document library - and the Folder option works as expected.



FIGURE: The filter not working properly on Photo Library (returns whole list including folders) when a subfolder is specified in the filter.




FIGURE: The filter working correctly on Document Library as expected (returns subset of data)


In particular, this CAML will not work on a Photo Library where my List Name is 'PhotoLibrary' and my subfolder is '1':




<Query />
<ViewFields />
<QueryOptions>
<Folder>PhotoLibrary/1</Folder>
</QueryOptions>

No comments: