Calculated Value: How to add 5 days to a date field in a scoped application?

G_38
Mega Expert

How to add 5 days to a date field in a scoped application, while using the calculated value field? This is what I currently have.

//Take current date in the site visit field and add 5 days, the result is then displayed on site visit report due date field.
var siteVisitDate = current.u_site_visit_date;
//add 5 days to site visit date field.
var reportDueDate = '';

return reportDueDate; // return the calculated value

After looking online I think I have to use the following but how would I use is it in my scenario?

find_real_file.png

 

 

1 REPLY 1

SanjivMeher
Kilo Patron
Kilo Patron

You can use addDaysLocalTime in Scoped App.

Refer below link and example

https://developer.servicenow.com/dev.do#!/reference/api/orlando/server_legacy/c_GlideDateTimeAPI#r_G...

 

 

var siteVisitDate = new GlideDateTime(current.u_site_visit_date);

//add 5 days to site visit date field.

siteVisitDate.addDaysLocalTime(5);

return siteVisitDate; // return the calculated value


Please mark this response as correct or helpful if it assisted you with your question.