I am working with a SharePoint list that has a date & time type column called Change Window Start (internal name: Start_x0020_Time). I am using below code to highlight the item row and font color if change window start date is today but it is not working. Can someone help me correcting the code.
Again the data type is Date and time for change window start column.
<script type="text/javascript">
SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function() {
SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
OnPostRender: function (ctx) {
// get today's date
var today = new Date();
// zero out the time portion so we will only compare days
today.setHours(0,0,0,0);
var rows = ctx.ListData.Row;
for (var i = 0; i < rows.length; i++) {
// get the date set in your date YourDateField
var itemDate = new Date(rows[i]['Start_x0020_Time']);
// zero out the time portion so we only compare days
itemDate.setHours(0,0,0,0);
var rowId = GenerateIIDForListItem(ctx, rows[i]);
var row = document.getElementById(rowId);
if (row!=null&&itemDate === today) {
row.style.backgroundColor = 'red';
}
}
}
});
});
</script>
I tried using both display name and internal name for Change window start but neither of that works.FYI, I am working with SPOnline.