I have the JSLink function below which I copied about 99.9%. But when I run it for my List, I get the following error. It doesn't seem to know the what the listItem is. Could someone please explain what is wrong. This should have bee a simple function to do.
TypeError: Unable to get property 'style' of undefined or null referenceTypeError
(function () {
var overrideCtx = {};
overrideCtx.Templates = {};
overrideCtx.Templates.Fields = {
'ContractdaysLeft': {
'View' : HighlightRowOverride,
'NewForm' : HighlightRowOverride,
'EditForm' : HighlightRowOverride,
}
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
})();
function HighlightRowOverride(inCtx) {
for (var i = 0; i < inCtx.ListData.Row.length; ++i)
{
var listItem = inCtx.ListData.Row[i];
var iid = GenerateIIDForListItem(inCtx, listItem);
var row = document.getElementById(iid);
if (listItem.ContractdaysLeft < 90)
{
row.style.backgroundColor = "#FFF1AD";
}
}
}