Community Alums
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2022 05:09 AM
Hi Team,
I have a date field on a record producer, and what I would like to achieve is to set the due date on the created ticket 5 days before the date field on the record producer.
I attempted this through a business rule script -
(function executeRule(current, previous /*null when async*/) {
var sd = new GlideDateTime();
sd.setValue('rec_prod_field_name');
sd.addDaysUTC(-5);
current.due_date=sd.getDisplayValue();
})(current, previous);
Can someone please advise the best way to do this and how?!
Thanks,
Alex
Solved! Go to Solution.
Labels:
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2022 05:29 AM
Hi
You can try the below Code :
(function executeRule(current, previous /*null when async*/) {
var sd = new GlideDateTime(current.variables.date_variable_name); //Write down Variable name instead of 'date_variable_name' from record producer.
sd.addDaysUTC(-5);
current.due_date=sd.getDisplayValue();
})(current, previous);
Please mark my answer as Correct/Helpful based on impact.
Regards,
Gunjan Kiratkar
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2022 05:51 AM
Thanks you! 🙂