How to get logged in users time zone in scoped app?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2015 04:25 AM
Hi All,
We used to get logged in users time zone by "gs.getUser().getTZ();"
But in scoped app, we get "Evaluator: org.mozilla.javascript.EcmaError: undefined is not a function." error while using the above code.
Is there any alternative for getTZ()?
Thanks,
Priya
- Labels:
-
Scoped App Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2015 04:40 AM
I don't about scoped app, but below code you can try to get a logged in user timeZone if above code you mentioned does not work.
var gr = new GlideRecord('sys_user');
gr.get(gs.getUserID());
var timeZone = gr.time_zone; // variable timeZone will store the user time zone value, you can use it further for scripting.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2015 06:54 AM
Hi Deepak,
The code you mentioned doesn't work in the global app as well.. have u tried this code?
Thanks,
Priya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2015 07:15 AM
I did run it in scripts background and it printed the correct time zone for the user.
It wont print time zone if that is the system time zone
Else it worked
var gr = new GlideRecord('sys_user');
gr.get(gs.getUserID());
gs.print(gr.time_zone);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2015 11:43 AM
Hello , priyadarshini! try these:
var gr = gs.nowDateTime(); // date and time
or
var gr = gs.now() // Just time