Flow Designer script action date handling issue

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2019 11:38 PM
I don't understand how Flow Designer processes dates and times. I created a simple Script Action to test inputs and outputs. The first screenshot shows the script action. It's a very simple pass through of the date/time value as a date/time and as a string. The second screenshot shows that whatever date/time value you pass in as the date_time parameter, you get a date/time value that is shifted by several hours (or more depending on the various methods I've tried).
And finally, I ran some background scripts to see if I had a time zone discrepancy, which I don't think I do.
Please explain why the date shifts in the Script Action. And more importantly, what approach do I use so that I can copy the value without changing the time?
Thanks.
- Labels:
-
flow designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2019 11:54 PM
Hi Erik,
new GlideDateTime() would always give you GMT time
see in background script below
gs.info(new GlideDateTime()); // this will give GMT time
gs.info(new GlideDateTime().getDisplayValue()); // this will give your local time
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2019 10:44 PM
Hi Erik,
Any update on this?
Can you mark my answer as correct, helpful if you were able to achieve the requirement & close the thread. Thanks in advance.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2019 05:34 AM
I marked your response as helpful because it clarified for me that the GlideDateTime default value is in GMT format. But I think there's a bug in Flow Designer with dates. I submitted a HI ticket and will update here when I learn more. I see 2 issues in flow designer:
- The Date Time value passed into the Script Action is 1 hour less than GMT
- getDisplayValue does not return the local time but the same 1 hour less time
I implemented a workaround but want to find out if there's a bug in Flow or if there's still something I don't understand about how this process is supposed to work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2019 12:41 AM
Sure Erik
Do let us know the update from ServiceNow
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader