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'm making an Ajax call to the Lists web service to retrieve some items. I'd like to return results only from a specific view. Can I do that through CAML?

I have this so far - which the attribute 'listView' is not correct. Is there a way to include the List View Name in the query?:

<GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
    <listName>Entertainment Guides</listName>
    <listView>Max Spending Rates</listView>
    <viewFields>
        <ViewFields>
            <FieldRef Name="Title"></FieldRef>
            <FieldRef Name="What_x0020_to_x0020_Know"></FieldRef>
        </ViewFields>
    </viewFields>
</GetListItems>
share|improve this question
add comment

1 Answer

After a quick look at the code, I realized two problems:

  1. The name I was using to refer to the view was incorrect, so I've switched to the GUID
  2. The attribute should be called 'viewName' instead of 'listView'

So, the working code is this:

<GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
    <listName>Entertainment Guides</listName>
    <viewName>{7DEBCA83-9228-4E2F-B7CB-C94C54DF170D}</viewName>
    <viewFields>
        <ViewFields>
            <FieldRef Name="Title"></FieldRef>
            <FieldRef Name="What_x0020_to_x0020_Know"></FieldRef>
        </ViewFields>
    </viewFields>
</GetListItems>
share|improve this answer
add comment

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.