I am using this code to retrieve data from my sharepoint list. Regardless of my Null check I still get the error saying unable to get property or null reference.

        url: _spPageContextInfo.webAbsoluteUrl + requestUri,
        type: "GET",
    headers: {
            "accept": "application/json;odata=verbose",
            success: function (data) {
                $.each(data.d.results, function (i, item){
                    var stat = item.MijnStatus;
                    var ltiov = item.LTIOV;
                    var reply = item.Reply;
                    var periode = item.Jaar;
            if (periode == myYear || stat == 'Completed') {
                                     if (reply != null){
                                     if (ltiov != null){
                var randomColor = '#' + Math.floor(Math.random() * 16777215).toString(16);

               // fnGenerateChart(xValues, yValues);

            error: function () {
                alert("Something went wrong");
  • At which line are you getting this error? Instead of using item[i].LTIOV, try using item.LTIOV. Let me know if this works? Mar 8, 2022 at 8:24
  • Ganesh indeed this works! The only thing not working is this line: if (periode == myYear || stat == 'Completed') . I still get all items also the ones not Completed.
    – Marco
    Mar 8, 2022 at 8:30
  • You are using **OR**(||) operator in condition. Are you sure you want that? You are getting items that are not completed because those items satisfies first condition (periode == myYear). If you want both conditions to satisfy, use if (periode == myYear && stat == 'Completed'). Mar 8, 2022 at 8:52
  • 1
    That makes sense, thanks a lot!
    – Marco
    Mar 8, 2022 at 8:57
  • Great, glad it worked for you. Mar 8, 2022 at 9:14

1 Answer 1


To solve this error, use item.LTIOV instead of using item[i].LTIOV as you are getting complete list item object in item variable inside for each loop.

Updated from comments:

To get only "Completed" items, use if condition like below:

if (periode == myYear && stat == 'Completed') {  }

Your Answer

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

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