Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

client script to add 1 year to current date

Laxmi18
Tera Expert

client script to add 1 year to current date i.e., System created date.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

like this in the onLoad or onChange client script

var todayDate = new Date(new Date().setFullYear(new Date().getFullYear() + 1)); // Now

g_form.setValue('valid_to', todayDate.toISOString().slice(0,10));

Regards
Ankur

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

View solution in original post

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

like this in the onLoad or onChange client script

var todayDate = new Date(new Date().setFullYear(new Date().getFullYear() + 1)); // Now

g_form.setValue('valid_to', todayDate.toISOString().slice(0,10));

Regards
Ankur

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