- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2015 05:01 PM
I recently encountered the same issue in trying to implement custom dimensions for Google Analytics. I wanted to add a dimension based on user roles. There is a way to do it without a GlideAjax call, though I must say this is about as far into the weeds as you can get from a platform perspective.
View the page source within ServiceNow, and about 60 lines down you'll find:
window.NOW.user = {};
window.NOW.user.preferences = [];
window.NOW.user.roles = 'admin';
window.NOW.user.id = '6816f79cc0a8016401c5a33be04be441';
window.NOW.user.departmentID = 'a581ab703710200044e0bfc8bcbe5de8';
window.NOW.user.firstName = 'System';
window.NOW.user.lastName = 'Administrator';
window.NOW.user.name = 'admin';
Within your UI Script, you can reference these variables, in particular the window.NOW.user.roles variable, to get the list of roles for the current user.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2016 01:07 PM
Hey Scott,
It looks like cheat code. But it helped me. Thank you for sharing this.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2021 11:41 PM
Hey Scott,
window.NOW.user.roles doesn't work in portal, any guidance?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2021 12:11 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2021 03:55 PM
You can use top.window.NOW object which has many different useful attribute as below:
top.window.NOW.instance_name
top.window.NOW.page_id
top.window.NOW.portal_id
top.window.NOW.portal_url_suffix
top.window.NOW.user_display_name
top.window.NOW.user_id
top.window.NOW.user_id_hashed
top.window.NOW.user_impersonating
top.window.NOW.user_initials
top.window.NOW.user_name
Cheers
Syed.