I want to add 14 days to the updated time and need to be showed in calendar_duration field

pyella
Tera Expert

I want to add 14 days to the updated time and need to be showed in (calendar_duration) duration field on the incident form in the form of days hours and minutes

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@pyella 

when should this be done? before insert of the record? which field holds the Updated time?

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

This should be done for after insert of record.

@pyella 

you can use before insert BR then on that table

you can use GlideDateTime API to add days

what script did you start with and where are you stuck?

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

pyella
Tera Expert

i am using before insert business rule only and i have use gludeDateTime to add days, here is the code i am using fro your reference,

Business rule :

var dur = current.u_minimum_lead_time; // minimum lead time is duration type

var glideObject = new GlideDateTime(dur); 

glideObject.addDays(14);

current.u_minimum_lead_time = glideObject;

 i am using the above code, but days are not populating as expected also i have to add 48 hours in different senario to the same field.