Notifications

36 views

Description

Inside a flow action if there is a script which stores GlideDateTime object in a local variable and when this variable is passed as an output  variable of type String or Date/Time, after the flow execution, the date/time displayed on flow execution details page is in different format. ie. It displays date/time in User's timezone instead of UTC [internal format].

Example: There is a flow action with following code in the script section:

(function execute(inputs, outputs) {
// ... code ...
var current_datetime = new GlideDateTime();
outputs.current_datetime = current_datetime; 
outputs.current_datetime_in_datetime = current_datetime; 
gs.log("*** GlideDateTime object *** " + current_datetime);
})(inputs, outputs);

where 'current_datetime' is an output variable of type 'String' and 'current_datetime_in_datetime' is an output variable of type 'Date/Time'

After the flow execution, the date/time displayed in

System log will be : *** GlideDateTime object *** 2020-01-22 01:53:30 // in UTC 

On flow execution details page the output variables will be :

current_datetime 21-01-2020 17:53:30 // in User's timezone
current_datetime_in_datetime 21-01-2020 17:53:30 // in User's timezone

Cause

On Flow execution details page, date/time will be displayed using the value from GlideDateTime.getDisplayValue() which displays date/time in User's timezone.

Resolution

On Flow execution details page, if you want date/time to be displayed in UTC, then inside the script use the value from GlideDateTime.getValue() method.

ie. Change the script to 

(function execute(inputs, outputs) {
// ... code ...
var current_datetime = new GlideDateTime();
outputs.current_datetime = current_datetime.getValue()
outputs.current_datetime_in_datetime = current_datetime.getValue()
gs.log("*** GlideDateTime object *** " + current_datetime);
})(inputs, outputs);

After the flow execution, the date displayed in

System log will be : *** GlideDateTime object *** 2020-01-22 01:53:30 // in UTC 

On flow execution details page the output variables will be :

current_datetime 2020-01-22 01:53:30 // in UTC
current_datetime_in_datetime 2020-01-22 01:53:30 // in UTC

 

Additional Information

To learn more about GlideDateTime API and its methods, refer below documentation link

https://docs.servicenow.com/bundle/newyork-application-development/page/app-store/dev_portal/API_reference/GlideDateTime/concept/c_GlideDateTimeAPI.html

Article Information

Last Updated:2020-01-29 21:11:10
Published:2020-01-30