- 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:22 PM
just a little more help
gs.print("User id is " +sgp.getDisplayValue('user'))
above line only print the user name, actually i want to print the corresponding user id also.
but when i tried with
gs.print("User id is " +sgp.getDisplayValue('user.user_id'));
it return null
can you please suggest some modification.
again thanks for your time above code is really helpful

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2017 04:26 PM
Hello Shiva,
As mentioned earlier you need to dot-walk to get user_id i.e code should be sgp.getValue('user.user_name')

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2017 04:32 PM
Shiva,
Small correction. Replace user_id with user_name. User ID is the column label name. Sorry for the confusion.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2017 04:33 PM
hello pradeep
i tried below codes
sgp.getValue('user.user_id') ,
sgp.getValue('sys_user.user_name')
sgp.getValue('sys_user.user_id')
sgp.getValue('user.user_name')
but all are returning null
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2017 04:38 PM
Can you paste your full query here