My goal is to read columns from the list TestList and write the element into an other list's new form's textbox TestText. But looks like even if I can acces the TestList the script return only with nulls. For example if the targeted column Szam have 4 elements then it return with 4 null if I add one more element it returns with 5 null, but I can't figure out why not contains the right values. Here is my code:

$(document).ready(function () {

            fields: "Szam"
        function getData(data)
            for (var i = 0; i < data.length; i++) {
               // $("#TestText").val(data[i].getAttribute("Szam"));

Both SP list is under the same site. I am using SP 2013, jquery.min.js and sharepointplus-4.0.min.js. The column Szam contains 5 element as text {1,2,3,4,5}. I as a result I can see the "null"s in the console log 5 times. In the final version I am planning to add something like where 'Szam = "5"' and search in other columns to get only 1 element as result and insert it to the TestText. I am new to both SP and JS so it can be even trivial mistakes. Thank you very much for your kind help!

  • Check the internal name of the field is Szam. I suspect the field name was Title which you renamed to Szam? – Amal Hashim Oct 3 '17 at 12:40
  • "Szam" is a new column, I didn't touch the "Title" column. The list contains 3 column: "Title", "Nev", "Szam". So u suspect it not accessing the right column just see that the list generaly have 5 rows? – Nefri Oct 3 '17 at 12:46
  • I created this list to be very simple so all names contains no blank " "-s, no special characters and no changed titles. The internalname of the "Szam" column is: "List=%7B7632DCD3%2D4F1B%2D4F8E%2DAC8C%2DFB9C4372CD3D%7D&Field=btyn" – Nefri Oct 3 '17 at 12:54
  • I am new to SharePointPlus.. not sure if you we need pass the View parameter along with fields. – Amal Hashim Oct 3 '17 at 12:57
  • I tested now an looks like even if I change the "Szam" to random characters like "Column123" or "btyn" the result is the same so it rly not finding the right column by his name :/ – Nefri Oct 3 '17 at 13:01

Thanks for using my Library :-)

First thing: the parameter is view, not views (see documentation).

Then, are you into the same website where you're doing the above code? If yes, no need to provide the URL. Also try to remove the view and add a where clause:

$SP().list("TestList").get({fields:"ID,Szam", where:"ID > 0"}, function(data)   {
  console.log("len => ",data.length); // to check the number of results
  data.forEach(function(d) {

Check the console of your browser to see the result.

Also, check the response body from the console to see what the server returned to you. It usually is a good way to see what might be wrong.

| improve this answer | |
  • Thank you very much! Your libary is very useful! In the end I figured out my problem was rly the field nameing. Sahrepoint some time create exactly the same name as the displayname and sometimes full random characters (even if I don t use any special character). (Maybe based on the field type) Someone told me I should use the displayname, but looks like I had to use the name from the URL. I checked this option before too, so I don't know why I didn't notice is that time, maybe I got other problems too when I checked it. – Nefri Oct 5 '17 at 12:52

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.