I have modified the following script to display my ReminderDate field in red if the date is past and also the feedback field is false.
Before implementing this and because I am a novice in jslink/javascript can anyone validate this code?
(function () {
var statusFieldCtx = {};
statusFieldCtx.Templates = {};
statusFieldCtx.Templates.Fields = {
"ReminderDate": {
"View": ColorCodeDueDate
}
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(statusFieldCtx);
})();
function ColorCodeDueDate(ctx) {
var _feedbackValue = ctx.CurrentItem.FeedbackReceived;
var dueDate = new Date(ctx.CurrentItem.ReminderDate);
var now = new Date();
// if there's no due date don't render anything
if (dueDate == 'undefined' || !dueDate) {
return '';
}
else if (dueDate <now && _feedbackValue == false) {
return "<div style='color:red'>" + dueDate.toLocaleDateString('en-GB') + "</div>";
}
else {
return "<div>" + dueDate.toLocaleDateString('en-GB') + "</div>";
}
}
ctx.CurrentItemobject to see what that value really is and how you can work with it. Also, at a quick glance, the way you have written your code implies that the internal name of the "feedback" field isfeedback- starting with a lower case "f". Is that really the case? – Dylan Cristy May 25 '16 at 13:58