
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2017 09:35 PM
I want to fetch the group members of a particular group in an array and use it further.
I am using below code but it doesn't return the sys IDs of all members, it returns only sys id of one member multiple times.
var users = [];
var gr = new GlideRecord('sys_user_grmember');
gr.addEncodedQuery("group=b8c3923613038b0014145a132244b05a");
gr.query();
gs.print("query success");
while(gr.next())
{
users.push(gr.user);
//users = users + gr.user + ',';
gs.print("yes");
gs.print("users: "+users);
}
gs.print(users.length);
Where am i going wrong ? Any suggestions would be helpful.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2017 09:39 PM
Hey Vineetha,
update your users.push(gr.user) to users.push(gr.user+'');

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2017 09:37 PM
Following are the logs after executing above script:
*** Script: query success
*** Script: yes
*** Script: users: 2e826bf03710200044e0bfc8bcbe5de0
*** Script: yes
*** Script: users: c6826bf03710200044e0bfc8bcbe5d87,c6826bf03710200044e0bfc8bcbe5d87
*** Script: yes
*** Script: users: ca826bf03710200044e0bfc8bcbe5d89,ca826bf03710200044e0bfc8bcbe5d89,ca826bf03710200044e0bfc8bcbe5d89
*** Script: 3
It just overrides the sys IDs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2017 09:39 PM
Hey Vineetha,
update your users.push(gr.user) to users.push(gr.user+'');

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2017 09:49 PM
Thank you so much. It is working correctly now.