Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

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