- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2020 01:49 AM
hi,
i have to Check the Groups of an User.
I get the Userinformations from a Field through a GlideRecord
gr.board.owner.getValue()
No i have the SysId but how i can Check the Group or Roles?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2020 02:53 AM
hey hi Please try below:
function test(){var VTBOwner="9da66f651b3333009998da49cc4bcb63";//put VTBowner=grCard.board.owner.getVale();
var gr= new GlideRecord('sys_user_grmember');
gr.addQuery('user', VTBOwner);
gr.query();
while(gr.next()) {
if(gr.group=='0a52d3dcd7011200f2d224837e6103f2')// sys id of group1
{
gs.log('yes');
}
else {
gs.log('no');
}
} }
test();
i have tested it output SS:
tthanks!!
if this helps then please mark if correct and helpful
Regards,
ajay
[ Architect | Certified Professional]
Was this response helpful? If so, please mark it as ✅ Helpful and ✅ Accept as Solution to help others find answers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2020 02:53 AM
hey hi Please try below:
function test(){var VTBOwner="9da66f651b3333009998da49cc4bcb63";//put VTBowner=grCard.board.owner.getVale();
var gr= new GlideRecord('sys_user_grmember');
gr.addQuery('user', VTBOwner);
gr.query();
while(gr.next()) {
if(gr.group=='0a52d3dcd7011200f2d224837e6103f2')// sys id of group1
{
gs.log('yes');
}
else {
gs.log('no');
}
} }
test();
i have tested it output SS:
tthanks!!
if this helps then please mark if correct and helpful
Regards,
ajay
[ Architect | Certified Professional]
Was this response helpful? If so, please mark it as ✅ Helpful and ✅ Accept as Solution to help others find answers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2020 03:19 AM
Yes, i think that the only way ist to use a GlideRecord on the Groupmember Table.
I cant find wa way to use the GlideUser Methods for another user as current. Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2020 03:24 AM
i used:
var userObj = gs.getUser().getUserByID(userSysID);
userObj.hasRole('role');
https://developer.servicenow.com/app.do#!/api_doc?v=newyork&id=GUser-getUserByID_S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2020 03:47 AM
thanks for sharing this too
[ Architect | Certified Professional]
Was this response helpful? If so, please mark it as ✅ Helpful and ✅ Accept as Solution to help others find answers.