Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a list with only one view exposed on it (default view). That list has a filter with a field Assigned To = [Me] so all users logged in can only see their own list items. This list items get copied from a master list.

I have this code to get the list items from the list with only one view but it only returns the items assigned to myself (as expected). Is there anyway to get all list items in a list regardless of the view?

  var xmlDoc = new XmlDocument();
  XmlNode query = xmlDoc.CreateNode(XmlNodeType.Element, "Query", "");
  XmlNode viewFields = xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields", "");
  XmlNode queryOptions = xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", "");
  queryOptions.InnerXml = "<MeetingInstanceID>-1</MeetingInstanceID><ViewAttributes Scope='RecursiveAll' />";
  return destLists.GetListItems(listConfig.DestGuid,
                                listConfig.DestViewGuid,
                                query,
                                viewFields,
                                RowLimit,
                                queryOptions,
                                null);
share|improve this question

1 Answer 1

up vote 3 down vote accepted

Your second node is the viewName, defined as:

A string that contains the GUID for the view surrounded by curly braces ({}), which determines the view to use for the default view attributes represented by the query, viewFields, and rowLimit parameters. If this parameter contains an empty string, the default view is used. If the view GUID is supplied, the value of the query, viewFields, or rowLimit parameter overrides the equivalent setting within the view. For example, if the view specified by the viewFields parameter has a row limit of 100 rows but the rowLimit parameter contains 1000, then 1,000 rows are returned in the response.

Source: MSDN - Lists.GetListItems Method

Since you're passing empty strings for query, viewFields, and rowLimit, you're getting the default view, exactly as defined in the list.

To override the Assigned To = [Me], you'll have to write the query to have different parameters. The referenced page gives examples of how to write the query XML.

share|improve this answer
    
@Jim, thanks, threw a custom query in the query node and got all the items :) –  Luke Hutton Mar 10 '11 at 22:46
    
Excellent!!!! Glad to have helped! –  Jim Bob Howard Apr 1 '11 at 13:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.