1

So Ive been sitting for half a day already trying to solve that. I have been able to successfully run the following query to find a value of another column on a small test-list:

$(document).ready(function() {
var raz = "raz";
var queryLookup = "<Query><Where><Eq><FieldRef Name='Title'/><Value Type='Text'>raz</Value></Eq></Where></Query>";
var itemfield="";

$().SPServices({
    operation: "GetListItems",
    async: false,
    listName: "Testowa",
    CAMLViewFields: "<ViewFields><FieldRef Name='kolumna'/></ViewFields>",
    CAMLQuery: queryLookup,
    completefunc: function(xData,Status) { 
        itemfield = $(xData.responseText).find("z\\:row").attr("ows_kolumna");;
alert(xData.responseText);
      } 
   });

  alert(itemfield); 

});

but as soon as I try applying it to a bigger list (less than 5k elements though) it just does not want to work and gives me no elements found and the following message in console: SCRIPT5007: Unable to get property 'B' of undefined or null reference shellcoreprimeg2m_6bed6c50.js (22,23129)

Messege I get

Does anyone have any idea as to why this happens?

5
  • From the xml it shows that it returns 0 items , Please make sure that the caml query returns the required list item , test this query using CAML Builder and check the results .
    – Esaki
    Commented Sep 26, 2017 at 13:33
  • I just did and it finds a result when i search using the title column that contains unique ID which is just a string of letters and numbers. But when i try to search using the name column (and that is what i want to do) it does not find any. An example of the name Im using is: "Płyta Plexiglas gs standard bezbarwny 2mm 2030x3050". Could this be too complicated a string for it to search for?
    – Kloggy
    Commented Sep 26, 2017 at 13:48
  • I just checked with a simple name "aaa" and it does find a result. Problem is I can't really change the names of the products (all 15000 of them especially...) so any ideas how could i make it work with the long names?
    – Kloggy
    Commented Sep 26, 2017 at 13:52
  • try to build a query with filter option contains instead of equals to ...
    – Esaki
    Commented Sep 26, 2017 at 14:27
  • I don't think you can use "contains" in CAML when you have more than 5000 items Commented Sep 26, 2017 at 14:58

1 Answer 1

1

Okay so I found a solution I think - just playing around with the CAML builder. It appears that if you change <FieldRef Name='Title'/> to <FieldRef Name="Title"></FieldRef> it suddenly starts working.

Answering some comments: It does not matter if I use contains or Eq, it did not work for both, but it works for both now. The list has less than 5000 items.

I hope this helps if someone runs into a similar problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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