Setting current date and time in a Flow

Mahesh_Krishnan
Giga Guru

OK.  I know this should be real simple but not getting the code to work.

I am setting a date field using a script instead of a data pill in one of the steps in a flow using the following code:

var invite_dt = gs.nowDateTime();

return invite_dt;

The system keeps resetting the above code to just GlideDateTime. 

I have spent an hour figuring this seemingly simple task out and now reaching out to the experts here.

Thanks in advance!

Mahesh

1 ACCEPTED SOLUTION

Kieran Anson
Kilo Patron

If you're just wanting to set a field in flow to be the current time, GlideDateTime will work

find_real_file.png

You can even reference the community live stream

View solution in original post

8 REPLIES 8

Mahesh_Krishnan
Giga Guru

Kieran:

I have tried your code multiple times; it is just not saving it.  I am not sure if this is SN's way of saying that is bad code but that is what is happening.  I have no information on what is wrong.

Kieran Anson
Kilo Patron

If you're just wanting to set a field in flow to be the current time, GlideDateTime will work

find_real_file.png

You can even reference the community live stream

Shubham Bongulw
Giga Guru

Hi Mahesh,

Use GlideDateTime() in your code.

The code should be like-

var invite_dt=new GlideDateTime();

return invite_dt.getDisplayValue();

 

Warm Regards,

Shubham Bongulwar

Please mark helpful or correct if it helps!!!

 

Mahesh_Krishnan
Giga Guru

Phew..finally!  Thanks Kieran.  Thanks Shubham!