
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2022 02:13 AM
Hi All,
I have a requirement to always set the due date of a specific record producer always to 24 hours after the created date/ always the next day.
How can I achieve this?
Thanks!
Alex
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2022 03:41 AM
Hi,
why not use record producer script itself and you don't need any extra BR etc?
var gdt = new GlideDateTime();
gdt.addDaysUTC(1);
current.setValue('due_date', gdt.getValue());
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2022 02:25 AM
Hi Alex,
Please try this
create a business rule on RITM
when to run : before insert
var createdDate = current.created;
var gr = new GlideDateTime(createdDate);
gr.addDaysLocalTime(1);
var test = gr.toString();
gs.log(test);
current.setValue('u_due_date', test);
Or add below line to Dictionary Entry Default value (Configure Dictionary ->default value)for due_date field
javascript: var d = new GlideDateTime(); d.addDaysLocalTime(1); d.getDisplayValue();
Mark Correct or Helpful if it helps.
***Mark Correct or Helpful if it helps.***

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2022 02:31 AM
Found your old thread maybe you can try to set 1 day here and try too
Set due date from record producer field date (X days before date)?
***Mark Correct or Helpful if it helps.***

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2022 02:43 AM
Hi there,
thanks for getting back to me!
What do I replace 'test' with?
Thanks,
Alex

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2022 02:51 AM
I have tried your script and the below script with no luck -
(function executeRule(current, previous /*null when async*/) {
var sd = new GlideDateTime(current.created); //Write down Variable name instead of 'date_variable_name' from record producer.
sd.addDaysUTC(1);
current.due_date=sd.getDisplayValue();
})(current, previous);