The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Compare date fields.

Taaha M
Tera Contributor

I have one date field on “dmn_demand” table and other on “dmn_demand_task” table.

The field “Planned Start Date” on Demand table should not be after “Due date” on Demand Task table.

5 REPLIES 5

svirkar420
Giga Guru

Hey @Taaha M , Try this below business rule for your requirement, 

When to run - before insert and update

(function executeRule(current, previous /*null when async*/) {
// Only check if Planned Start Date has a value
if (gs.nil(current.planned_start_date)) {
return;
}

var taskGR = new GlideRecord("dmn_demand_task");
taskGR.addQuery("demand", current.sys_id); 
taskGR.query();

while (taskGR.next()) {
if (!gs.nil(taskGR.due_date) && current.planned_start_date > taskGR.due_date) {
gs.addErrorMessage("Planned Start Date on Demand cannot be after the Due Date of associated Demand Task(s).");
current.setAbortAction(true); 
break;
}
}
})(current, previous);

 

If this solution helped you Please Mark this solution as accepted and helpful as it will be helpful for other users as well.
Best Regards.
Saurabh V.