How to set the time zone for the user session in a Business Rule ? - Scoped Application.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-29-2020 10:11 PM
How to set the time zone for the user session in a Business Rule ? - Scoped Application.
Any suggestions please...
gs.getSession().setTimeZoneName("Asia/Kolkata");
Output:
Evaluator: org.mozilla.javascript.EcmaError: Cannot find function setTimeZoneName in object com.glide.script.fencing.ScopedGlideSession@e00b31. Caused by error in script at line 1 ==> 1: gs.getSession().setTimeZoneName("Asia/Kolkata");
- Labels:
-
Scoped App Development
-
Studio
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-29-2020 11:43 PM
Hi Sahu,
the glidesession class in scoped app doesn't have that method it seems
check links below
https://snprotips.com/blog/2017/9/12/handling-timezones-in-servicenow-timezoneutil
https://gist.github.com/thisnameissoclever/b196fb32ccfeaebce919907af819d734
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
02-13-2022 02:57 AM
Hi,
You can set session timezone from ScopedApp using TimezoneAjax ScriptInclude which located in Global scope but is available from other scopes.
var userTZ=gs.getSession().getTimeZoneName(); //Save user timezone
var gTz=new global.TimezoneAjax();
gTz.changeTimeZone('US/Pacific'); // Set custom timezone
// Do what you need
gTz.changeTimeZone(userTZ); // Restore user timezone