
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2020 10:32 AM
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
Solved! Go to Solution.
- Labels:
-
flow designer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2020 09:09 PM
If you're just wanting to set a field in flow to be the current time, GlideDateTime will work
You can even reference the community live stream

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2020 10:38 AM
Hi,
It should be new GlideDateTime(); as your function rather than using the glide system method.
var invite_dt = new GlideDateTime();
return invite_dt.getDisplayValue();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2020 10:39 AM
var gr = new GlideRecord('table_name');
gr.invite_dt = gs.nowDateTime();
You need not return here, unless you are calling a function. You did miss a GlideRecord into the table where your field (date field) lies. That's all. You create a object for the table and using the object, you store the value fetched via nowDateTime() GlideSystem method into your date field.
Try the solution from Kieran as well and let us know what went well in this case. I would be happy to correct myself in my learnings, if this is wrong.
Mark as Correct Answer if this response helped you solve your query, and mark it helpful as well.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2020 03:03 PM
Anish:
When I tried your code I got an error stating that the code needs to return a value.
Kieran:
The GlideDateTime() class manipulates existing dates; it does not set the current system date.
I was not able to get the flow to even accept the code. Not sure if I am doing something wrong here.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2020 01:05 AM
I realize the mistake I did. Thanks for notifying.