1

Here is the list (please note 'Full Name' column has been changed to 'FullName' since I took this shot: enter image description here

Here is the CAMLQuery:

$(document).ready(function() {

    var camlQuery = "<View><Query><Where><Eq><FieldRef Name='ows_Branch' /><Value 
    Type='Choice'>Headquarters Support (MEAD)</Value></Eq></Where></Query></View>";  

    $().SPServices({
        operation: "GetListItems",
        async: false,
        listName: "{E9E9983E-FECC-49DC-BA8D-4D0AE236C3C1}",
        CAMLQuery: camlQuery,
        CAMLViewFields: "<ViewFields><FieldRef Name='FullName' /></ViewFields>",
        completefunc: function (xData, Status) {
            $(xData.responseXML).SPFilterNode("z:row").each(function() {
                var liHtml = "<span>" + $(this).attr("ows_FullName") + "</span>";
                $("#HSMEAD").append(liHtml);
            });
        }
    });
});

I just need to pull the full name from each branch and division and append it to a div. The caml query is not working but if i comment that out, the CAMLViewFields works fine and renders ALL the names from 'FullName' into the div correctly.

If there is a way to do it with JS without the query I am interested.

UPDATE:

with @Marko Tica's help, here is a final query that works for me:

  $(document).ready(function() {
  $().SPServices({
    operation: "GetListItems",
    async: false,
    listName: "{E9E9983E-FECC-49DC-BA8D-4D0AE236C3C1}",
    CAMLQuery: "<Query><Where><Eq><FieldRef Name='Column6' /><Value 
    Type='Choice'>Headquarters Support (MEAD)</Value></Eq></Where></Query>",
    CAMLViewFields: "<ViewFields>  <FieldRef Name='FullName' /> 
    </ViewFields>",
    completefunc: function (xData, Status) {
      $(xData.responseXML).SPFilterNode("z:row").each(function() {
         
       var liHtml = "<span>" + $(this).attr("ows_FullName") + "</span>";
           $("#HSMEAD").append(liHtml);

         });
       }
     });
    });
   </script>
2
  • 1
    Go to list > list settings> click on Branch column and in url you have Internal name of that column &Field=InternalNameOfBranchColumn. Put that internal name in query and add in viewfields (Title, Branch and Fullname)
    – Marko Tica
    Sep 9 '20 at 10:19
  • that didn't do it for me...still wont render anything that looks like a query Sep 9 '20 at 15:15
1

Remove <View> from query

Link https://williamwmy.wordpress.com/2013/05/13/using-spservices-with-camlquery-to-get-listitems/

1
  • 1
    I used "column6" instead of branch, removed view but I think that link you have from wordpress is really good in setting up the query. I restructured my query using that and it all works! Sep 10 '20 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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