Set date to a set field activity in a workflow

ServiceNow Adm1
Giga Contributor

I have a requirement to set current time and tomorrow's date to a date-time field in a workflow.

 

Let say current time is 5 PM and date is 9th March. I have to set 10-03-2020 05:00:00.

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Srini,

Are you saying you want to set it to next date and time as 5pm?

if yes then you can set that using script; you cannot set it to next date using set value activity since it would accept static value; use run script activity

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

Suseela Peddise
Kilo Sage

Hi,

You can use run script activity to set the date/time.

Script:

var start_date=current.variables.<<variable name>>; //replace the variable name

var gdt = new GlideDateTime(start_date);

gdt.addDays(1);

current.<<variable name>> = gdt;

 

If I have answered your question, please mark my response as correct and/or helpful.

Thanks,

Suseela P.

Krishna  Penaka
Tera Expert

You can use 'Set Values' activity in your workflow to set all the values.

 

Example-

 

In the 'Set Values' activity in your workflow you can use below-

 

Set -

 

Resolved - javascript:gs.nowDateTime()

 

Resolved By - javascript:gs.getUserID()

 

and so on.