The CreatorCon Call for Content is officially open! Get started here.

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.

13 REPLIES 13

@Taaha M 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Taaha M , Have you tried implementing solution I have posted? Where are you stuck now?

 

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.

svirkar420
Tera 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.

@Taaha M , Hope you are doing well, Did my reply answer your question? Where are you stuck now?

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.

Hi @Taaha M , Did my answer helped you in completing your requirement?

If my answers given earlier were helpful then Please Mark this solution as accepted and helpful as it will be helpful for other users as well.
Best Regards.
Saurabh V.