How do you force your flow to calculate the correct DST offset even if your SNow instance has its system configurations set to GMT?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2022 03:40 PM
Hello,
How do you force your flow in Flow Designer to calculate the correct daylight savings time offset to accommodate users who use Central time zone in their ServiceNow instance profile even if the ServiceNow instance's system configuration is set to GMT?
Background:
Up until March 13, 2022, our script within a flow to calculate the DST offset was working in Flow Designer. Then the daylight savings happened, and suddenly it stopped working and kept returning an offset of 0 when it should be returning 3600000.
We opened a ticket with ServiceNow support and their response was, it's behaving by design because the instance system config is set to GMT.
This is a sample of the script that used to work before March 13, 2022 and the previous year:
var gdt = new GlideDateTime("2022-03-21 18:05:00"); //Scheduled Time
var gtime5 = new GlideTime(); //Variable for DST
var gtime6 = new GlideTime(); //Variable for non-DST
var offset = gdt.getDSTOffset();
gs.info(offset);
//Check if time is during Daylight Savings Time, add +5 to the UTC time
if (offset !== 0) {
gtime5.setValue("05:00:00");
gdt.add(gtime5);
scheduled_time = gdt; //Scheduled Time
gs.info(scheduled_time);
gs.info("Pick IF statement");
} else {
//Otherwise, add +6 to the UTC time when not during Daylight Savings Time
gtime6.setValue("06:00:00");
gdt.add(gtime6);
scheduled_time = gdt;
gs.info(scheduled_time);
gs.info("Pick ELSE statement");
}
Actual and Expected correct output:
3600000
2022-03-21 23:05:00
Pick IF statement
So how do you force your flow to get around this and still be able to calculate the DST offset since users are in Central time zone?
We're looking for a workaround...any help would be greatly appreciated.
Thank you in advance for your time,
Harriet
- Labels:
-
flow designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2022 10:26 AM
Users always enter date/time in Central time zone in an Excel spreadsheet as part of a bulk request. The flow in Flow Designer uses json parsing to parse through each row to extract data from the Excel spreadsheet. Our script in our flow determines whether it is daylight saving time right now or not as you can see in the script of my original post. Finally, that data is imported to a RITM via Service Catalog trigger.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2022 10:58 AM
In that case you could
- create a (service) user configured with CDT time zone and with the date/time format used in the excel sheet
- move the import logic into a sub-flow that is configured to run with this special, non-interactive, system user
- use GlideDateTime's setDisplayValue() method when loading the data from the spreadsheet.
That way the system will load the data knowing that it needs to interpret it in CDT time zone and will do all conversions needed.