- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2020 05:25 AM
Hi There,
I want to fetch the domain of current user in my script include.
i am using ...
var domain = gs.getUser().getDomainID();
gs.print('Domain ID is =='+domain )
This is giving me the domain of the user from domain picker. but i want to get the value which is there in the user table.
can i not get the value directly without gliderecording the user table?
Solved! Go to Solution.
- Labels:
-
Script Debugger
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2020 06:08 AM
Just to inform gs.getUser().getRecord().getValue('fieldName') won't work in scoped application
It would work in global scope.
For Global Scope:
gs.info('Domain ID is ==' + gs.getUser().getRecord().getValue('sys_domain'));
For Custom scope
better you query sys_user table for that user and get the domain value
var user = new GlideRecord('sys_user');
user.get(gs.getUserID());
gs.info('Domain ID is ==' + user.sys_domain);
Regards
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
08-13-2020 06:08 AM
Just to inform gs.getUser().getRecord().getValue('fieldName') won't work in scoped application
It would work in global scope.
For Global Scope:
gs.info('Domain ID is ==' + gs.getUser().getRecord().getValue('sys_domain'));
For Custom scope
better you query sys_user table for that user and get the domain value
var user = new GlideRecord('sys_user');
user.get(gs.getUserID());
gs.info('Domain ID is ==' + user.sys_domain);
Regards
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
08-13-2020 06:51 AM
Hi Ankur,
if gs.getUser().getRecord.getValue() doesnot work in scope app then it seems gliderecording is the only option left.
Thanks for the response!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2020 07:21 AM
You are welcome.
Regards
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader