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.
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + requestUri,
type: "GET",
async:false,
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') {
console.log(ltiov);
console.log(reply);
if (reply != null){
xValues.push(item[i].Reply);
}
if (ltiov != null){
xValues.push(item[i].LTIOV);
}
var randomColor = '#' + Math.floor(Math.random() * 16777215).toString(16);
barColors.push(randomColor);
}
// fnGenerateChart(xValues, yValues);
})
},
error: function () {
alert("Something went wrong");
}
});
item[i].LTIOV
, try usingitem.LTIOV
. Let me know if this works?||
) 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, useif (periode == myYear && stat == 'Completed')
.