- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2017 03:54 PM
How to the user id and group name of all the user name and group name listed in sys_user_grmember table using background script inside a variable or just print those details .
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2017 04:07 PM
Please use below background script to print user name and group name from sys_user_grmember table.
var sgp = new GlideRecord("sys_user_grmember");
sgp.addQuery('sys_id',"4c744323d711110050f5edcb9e6103e4"); // Please modify your query according to your requirements.
sgp.query();
while(sgp.next()){
gs.print("User id is " +sgp.getDisplayValue('user'));
gs.print("Group name is " + sgp.getDisplayValue('group'));
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2017 04:45 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2017 04:46 PM
yes got the exact output
thanks again

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2017 04:29 PM
Please use below code which prints user id, user name and group
var sgp = new GlideRecord("sys_user_grmember");
sgp.addQuery('sys_id',"287f3358a9fe19810109062e982279cf"); // modify query as per requirements
sgp.query();
while(sgp.next()){
gs.print("User name is " +sgp.getDisplayValue('user'));
gs.print("User ID is " +sgp.getDisplayValue('user.user_name'));
gs.print("Group name is " + sgp.getDisplayValue('group'));
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2017 04:42 PM
thanks
100% working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2025 06:26 AM