SharePoint’s SPList class contains the GetItems method which is used to query the contents of a SharePoint list. Rather than iterating through all of the list’s items, the GetItems method allows you to specify a collaborative application markup language (CAML) query to return just the collection of items in which you are interested. It is like sending a SQL query to the SharePoint list. Clearly this is an indispensible method to know about when dealing with any non-trivial list.
One would expect that in order for a call to GetItems to return data, the user invoking the code would need only Read permissions to the list. However, I have run into situations where a user had Read permissions to a list but the call to GetItems returned no data. I had already validated that the query worked by invoking the call to GetItems from another user.
In those situations I could not get a call to GetItems to return any data unless the user had at least Contribute permissions to the SharePoint web site that contained the list. This was the case even if the user had Contribute permissions to the list. Read permission to the SharePoint site or list were insufficient.
I have not yet had time to nail down exactly what circumstances or configuration settings trigger this behavior. If others have seen this behavior and have more insight, I’d love to hear about it. For now, if you have a GetItems call that should be returning data but is not, before spending hours or days changing around your code, try invoking the call from a user who has Contribute permissions to the site.
Do you think it is has to do with GetListItems pulling information which requires permissions more than Read.
Like Content approval and Check in Check out etc….
Have tried setting view fields to bare minimum like Title and then call using spquery
I'd thought about that. The list with which I most recently experienced the behavior did not have content approval turned on and did not have check-in / check-out capabilities as it was not a document library. Unlike the GetListItems web method, the GetItems method on the SPList class does not need to allow you to directly set view fields.
This might help u
http://snahta.blogspot.com/2009/09/spquery-returning-no-result.html
Thanks, Sandeep. Unfortunately, it does not help me as the CAML works in all environments, just not for all users. I did verify that the users for whom the CAML query did not work did have read access to the list items and could see them through the SharePoint user interface.
Thanks,
You saved me a few hours…