Variables - Auto populate

Vengeful
Mega Sage

Hello,

 

I have 2 variables for a specific request item that should be auto populate.

Valid from should be auto populate on the date of creation/submission.

Valid to is dependent to Validity.

If I select 1 week, the Valid to date should automatically populated based on the user’s selection.

Merza_0-1692670351884.png

Merza_1-1692670455698.png

 

How can I configure that kind of setup?

 

1 ACCEPTED SOLUTION

@Ankur Bawiskar 

I tried to add this on default value javascript:gs.nowDateTime() and it worked.

Merza_0-1692682585082.png

My problem now is the Valid to.

View solution in original post

15 REPLIES 15

Ankur Bawiskar
Tera Patron
Tera Patron

@Vengeful 

auto-populate based on which variable?

Is that variable a reference variable?

If yes then you can use Utah's auto-populate feature with no scripting

Auto-populate a variable based on a reference type variable (Utah) 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Hi @Ankur Bawiskar ,

Valid from and Valid to are the variables which the type is Date/Time

Merza_0-1692673627431.png

 

Let's say I will a submit, the Valid From should be auto populate on the day I will submit a request.
And for Valid to, If I select on the 1 week on the Validity, the Valid to should be 1 week from the Valid from.

 

@Vengeful 

are you having target fields for those 2 variables?

If yes and since you want to auto-populate the target fields the variables are not required as they won't be entered by user and will be calculated from script

you can use record producer script to set the value in target field

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

@Ankur Bawiskar 

I tried to add this on default value javascript:gs.nowDateTime() and it worked.

Merza_0-1692682585082.png

My problem now is the Valid to.