How to set a default value for a date/time field

Jerome MAISETTI
Mega Guru

Hello All
I have a date/time field which I would like to be set to three days from now as default when a ticket goes into Pending Customer.
How can I achieve this ? Can I put  a default value in the dictionary field or should I use a client script ?
Thanks

1 ACCEPTED SOLUTION

Mahendra RC
Mega Sage

Hello @Jerome MAISETTI 

You can use the below script in Before Update BR:

Condition: State is on Hold AND On hold reason changes to Pending Customer

Before update BR Script:

var nowGDT = new GlideDateTime();
nowGDT.addDays(3);
var nowDateNumericValue = nowGDT.getNumericValue();
current.<your_date_time_field_name>.setDateNumericValue(nowDateNumericValue);

 

View solution in original post

6 REPLIES 6

@Arun kumar Chin 

can you create a new question for this as this is an old thread and tag me there?

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

Jerome MAISETTI
Mega Guru

Thanks all! I managed to do it šŸ™‚