listItems qury with caml on taxonomy field

Jan 23, 2014 at 2:50 PM
The following code works fine when there is no query but gets error from the service when the caml is sent. the location is the number before the ";#" of value of ows_HRLocations
(I tried "Contains" on the string after but got the same error)

Can anyone Help?
function loadFromPages(){
    $().SPServices({
        operation: "GetListItems",
        async: false,
        listName: "Pages",
        CAMLViewFields: "<ViewFields><FieldRef Name='Title' /><FieldRef Name='PublishingPageImage' /><FieldRef Name='Name' /><FieldRef Name='NameTitle' /><FieldRef Name='FeaturedItem' /><FieldRef Name='HRLocations' /></ViewFields>",
        completefunc: renderStories,
        CAMLRowLimit: 100
  });
} 

  
function loadFromPagesBy(location){
    $().SPServices({
        operation: "GetListItems",
        async: false,
        listName: "Pages",
        CAMLViewFields: "<ViewFields><FieldRef Name='Title' /><FieldRef Name='PublishingPageImage' /><FieldRef Name='Name' /><FieldRef Name='NameTitle' /><FieldRef Name='FeaturedItem' /><FieldRef Name='HRLocations' /></ViewFields>",
        CAMLQuery: "<Query><Where><In><FieldRef Name='HRLocations' LookupId='TRUE'/><Values><Value Type='Integer>"+location+"</Value></Values></In></Where></Query>",
        completefunc: renderStories,
        CAMLRowLimit: 100
  });
} 
 
function renderStories(xData, Status) {
       var itemCount = $(xData.responseXML).SPFilterNode("rs:data").attr("ItemCount");
      //alert(itemCount);
      $('#container').empty(); //Clear
      $(xData.responseXML).SPFilterNode("z:row").each(function() {
            oneStory($(this));
      });
}
Coordinator
Jan 23, 2014 at 6:50 PM
Ofer:

There's no "<In>" with the SOAP Web Services. Try this:
        CAMLQuery: "<Query><Where><Eq><FieldRef Name='HRLocations' LookupId='TRUE'/><Value Type='Integer>"+location+"</Value></Eq></Where></Query>",
If you look at the Net tab in Firebug (or use Fiddler, etc.) you should see some sort of error from the operation in the response.

M.
Jan 23, 2014 at 10:54 PM
Even when the query is simple like this:CAMLQuery: "<Query><Where><Eq><FieldRef Name='HRLocations' LookupId='TRUE'/><Value Type='Integer>315</Value></Eq></Where></Query>",

I get "Status="error"
Jan 24, 2014 at 2:17 AM
Your CAML is invalid (status of error means that the browser is producing an error - in this case an XML error, I assume)

Your missing a single quote at the end of 'Integer'

Also, should it be Type='Counter' instead?

Paul


--
Paul T.

-- Sent from Mobile

Jan 24, 2014 at 1:41 PM
Good catch! thanks Paul!
turns out both 'Counter' and 'Integer' work the same.

My take away from this is, you need to query by the "LookupId" the number before the ;# in the row.attr("ows_XXX
That means you either have to bring all of them first or maybe query the hidden list first.

At list I learnt something :-) thank you all
Coordinator
Jan 24, 2014 at 2:11 PM
Sorry I missed the missing apostrophe in your original post, Ofer. I spotted the bigger issue first.

M.
Jan 24, 2014 at 8:56 PM
Congratulations you are human :-)