Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4023766
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:38:19+00:00 2026-05-20T10:38:19+00:00

Although I specify a ViewFields element in my sharepoint list service’s GetListItems query, all

  • 0

Although I specify a ViewFields element in my sharepoint list service’s GetListItems query, all fields are returned. The following code builds the request:

XmlDocument xmlDoc = new System.Xml.XmlDocument();
XmlNode query = xmlDoc.CreateNode(XmlNodeType.Element, "Query", "");
XmlNode viewFields = xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields", "");
XmlNode queryOptions = xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", "");    

... set query ...

viewFields.InnerXml = "<FieldRef Name='LinkFilename' /><FieldRef Name='FileDirRef' /><FieldRef Name='FileLeafRef' />";            

queryOptions.InnerXml = "<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns><DateInUtc>TRUE</DateInUtc><Folder>Resource Management Tools</Folder><ViewAttributes Scope='Recursive' />";

XmlNode xmlNode = SharePointListWebService.GetListItems(
_listServiceConfigurationSettings.ListName,
                                string.Empty,
                                query,
                                viewFields,
                                null,
                                queryOptions,
                                null);

According to fiddler, this results in the following soap envelope being posted to the list service:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">    
      <listName>Shared Documents</listName>
      <viewName />
      <query>
        <Query xmlns="">
          <Where>
            <And>
              <Contains>
                <FieldRef Name="FileLeafRef" />
                <Value Type="Text">.xls</Value>
              </Contains>
              <Geq>
                <FieldRef Name="Modified"
                IncludeTimeValue="True" />
                <Value Type="DateTime">2010-05-10T11:53:32Z</Value>
              </Geq>
            </And>
          </Where>
          <OrderBy>
            <FieldRef Name="FileDirRef" />
          </OrderBy>
        </Query>
      </query>
      <viewFields>
        <ViewFields xmlns="">
          <FieldRef Name="LinkFilename" />
          <FieldRef Name="FileDirRef" />
          <FieldRef Name="FileLeafRef" />
        </ViewFields>
      </viewFields>
      <queryOptions>
        <QueryOptions xmlns="">
          <IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>
          <DateInUtc>TRUE</DateInUtc>
          <Folder>Resource Management Tools</Folder>
          <ViewAttributes Scope="Recursive" />
        </QueryOptions>
      </queryOptions>
    </GetListItems>
  </soap:Body>
</soap:Envelope>

and the following soap response being returned from the service:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <GetListItemsResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
      <GetListItemsResult>
        <listitems xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'
        xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'
        xmlns:rs='urn:schemas-microsoft-com:rowset'
        xmlns:z='#RowsetSchema'>
          <rs:data ItemCount="19">
            <z:row ows_LinkFilename='[SENSITIVE DATA].xls'
            ows_FileDirRef='278;#sites[SENSITIVE DATA]'
            ows_FileLeafRef='278;#[SENSITIVE DATA].xls'
            ows_MetaInfo='278;#Subject:SW| vti_parserversion:SR|12.0.0.6421 ContentTypeId:SW|0x0101006C2E647253A1074FB6079F08E5F2A395 _Author:SW|[SENSITIVE DATA] _Category:SW| vti_author:SR|[SENSITIVE DATA] _Comments:SW| vti_approvallevel:SR| vti_categories:VW| vti_cachedcustomprops:VX|vti_approvallevel vti_categories Subject vti_assignedto Keywords _Author _Category _Comments vti_assignedto:SR| Keywords:SW| vti_modifiedby:SR|[SENSITIVE DATA]'
            ows__ModerationStatus='0' ows__Level='1'
            ows_Last_x0020_Modified='278;#2010-06-29T18:55:38Z'
            ows_ID='278' ows_owshiddenversion='53'
            ows_UniqueId='278;#{0E51B2B1-89A7-4895-8ECC-0FE7D420470C}'
            ows_FSObjType='278;#0'
            ows_Created_x0020_Date='278;#2009-03-09T16:06:41Z'
            ows_ProgId='278;#' ows_Modified='2010-06-29T18:55:37Z'
            ows_FileRef='278;#sites[SENSITIVE DATA].xls'
            ows_DocIcon='xls'
            ows_Editor='262;#[SENSITIVE DATA]' />            
          </rs:data>
        </listitems>
      </GetListItemsResult>
    </GetListItemsResponse>
  </soap:Body>
</soap:Envelope>

Notice the z:row element has more fields included than I specified in my ViewFields criteria. I also set IncludeMandatoryColumns to false in my query options. Did I do something wrong or do I not understand how ViewFields really works as I thought it would limit the fields i.e. z:row attributes returned by the SharePoint list service.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:38:20+00:00Added an answer on May 20, 2026 at 10:38 am

    I’ve been struggling with this issue, too. Tonight I found a solution that seems to work for me…hopefully it’s helpful for others, as well.

    The structure of your viewFields node is fine…

       <viewFields>
        <ViewFields xmlns="">
          <FieldRef Name="LinkFilename" />
          <FieldRef Name="FileDirRef" />
          <FieldRef Name="FileLeafRef" />
        </ViewFields>
      </viewFields>
    

    The problem is likely your field names. Apparently you have to use the internal names rather than the display names. One quick & easy way to determine the internal names is to go to the List Settings page for your list and hover over each column in the list. The browser’s status bar will show a URL similar to this..

    http://YOUR_SITE/_layouts/FldEdit.aspx?List=%7B12345678%2D1234%2D1234%2D1234%2D123456789012%7D&Field=INTERNAL_FIELD_NAME
    

    Use the internal field name shown there for each of the fields you want to return from the GetListItems() service. For example,

    <FieldRef Name="LinkFilename" />
    

    ….might need to be written as…

    <FieldRef Name="Link_x0020_Filename" />
    

    At least that’s what it took to solve the problem for me. Hope that helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.