Convert Time to different time zones based on the user's selection.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-27-2024 08:12 AM
Hi all,
I'm looking for some assistance in converting time from MST to other 5 different time zones on CR form field.
The 'actual work start' field will auto populate once the CR is moved to implement state and the time it's auto populating is MST irrespective of the selection in 'Time Zone' field. The time it should auto populate and convert into the time zone based on the time zone selected in 'Time Zone' field. I'm able to convert to other time zones accurately but the time in 'actual work start' field it's displaying is UTC time(may be I'm missing something here).
Here is the BR I've written when CR state is 'implement' run 'after' update/insert:
var gdt = new GlideDateTime(); //- utc
gs.print('utc time: '+gdt);
gdt.setTimeZone('US/Arizona');
gs.info('US/Arizona: '+gdt.getDisplayValue());
gdt.setTimeZone('US/Central');
gs.info('US/Central: '+gdt.getDisplayValue());
gdt.setTimeZone('US/Eastern');
gs.info('US/Eastern: '+gdt.getDisplayValue());
gdt.setTimeZone('US/Hawaii');
gs.info('US/Hawaii: '+gdt.getDisplayValue());
gdt.setTimeZone('US/Mountain');
gs.info('US/Mountain: '+gdt.getDisplayValue());
gdt.setTimeZone('US/Pacific');
gs.info('US/Pacific: '+gdt.getDisplayValue());
Output:
But while running the business rule with the same logic and setting it to 'Actual work start', it's displaying the UTC time instead of the converted time zone.
Any help is much appreciated, thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2025 08:32 AM
One use case that I am trying to solve is a using a record producer form where a user can select a location and request a visit time. The form will expect the time to be in the location's time zone and not the user's time zone. However, when submitting a form through the record producer on the service portal or CSM, the time is submitted as the user's time zone. Hence the time needs to be converted from the user's time zone to the location's time zone. I am having difficulty achieving a method to do this, considering the user's permissions as customers and the form running in the Customer Service application.
Anyone have any suggestions?