Compare date fields.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
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.