Add 2 days to the created date of a record in scoped application

SK41
Giga Guru

Hi,

 

I have a requirement where I have a case record in a custom scope application(customer service). I have to add two days to the created field for the record, and set the new date to a custom field, "updated date". For example, if the created date is 2024-04-17 13:10:122 then after adding two days it should be 2024-04-19 13:10:122.

 

How can i achieve this through script for a scoped application?

Kindly, suggest!

 

Thanks!

1 ACCEPTED SOLUTION

Alex Rose
Tera Guru

You have a few options for this with the Scoped GlideDateTime class (docs here). You could use the function addDaysLocalTime or addDaysUTC.

View solution in original post

2 REPLIES 2

Alex Rose
Tera Guru

You have a few options for this with the Scoped GlideDateTime class (docs here). You could use the function addDaysLocalTime or addDaysUTC.

abirakundu23
Mega Sage

Hi @SK41 ,

You have to use addDaysUTC() or addDaysLocalTime() for scoped application.
Follow this link for more information :GlideDateTime - Scoped (servicenow.com)
Please refer below screenshot & use 'addDaysUTC()' or 'addDaysLocalTime() ' for scoped application instead of addDays().

akadu23_0-1713376096564.png

Please mark helpful & accept the answer if it's really worthy for you.