Correct my code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2025 04:08 AM
Hi
I have a requirement where in i have to create a field named compliant in problem task and that field should be read only (this is done) and that should display Yes if the task is closed date is less than due date, and No the other way round.
I tried to achieve this via BR, and i am not getting the proper results.
Can you please correct me on what i did wrong.
Thanks
Code:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2025 07:55 AM
the code does not work for the else part, meaning if the record is getting closed after the due date the compliant should reflect as no that is not happening
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2025 07:48 AM
Hello @Abdul, If you want to keep the value as No always and Yes when due date is greater than closed date then, could you try as below
- BR should be configured to run Before and order as 2001 (as attached below)
- in the advanced section use following script:
(function executeRule(current, previous /*null when async*/ ) {
current.u_compliant = 'No';
var closed_date = new GlideDateTime(current.closed_at).getNumericValue();
var due_date = new GlideDateTime(current.due_date).getNumericValue();
if ( due_date > 0 & closed_date > 0 & due_date > closed_date )
current.u_compliant = 'Yes';
})(current, previous);
Regards,
Nishant