- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2024 12:30 AM
Tryin to crate array of sysids. Don't know why its not getting.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2024 12:12 PM
Hello,
You have to make correction to from gr.sys_id to gr.sys_id.toString(), because in gr.sys_id you are still referring to the same object. Also the best practice is to use the getter here like gr.getUniqueValue().
See the correction below:
var users = [];
var gr = new GlideRecord('sys_user');
gr.query();
while(gr.next()){
users.push(gr.sys_id.toString());
//users.push(gr.getUniqueValue());
}
gs.info(users);
Thank you,
Mahesh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2024 06:04 PM - edited 12-24-2024 06:04 PM
Hello @ObuM
Thank you for marking my response helpful.
As per the new community policy, you can mark multiple accepted solution.
Can you please mark the solution as accepted, it will help future readers to locate the solution easily in community.
Thank You
Juhi Poddar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2024 06:26 AM
this will work
var gr = new GlideRecord('sys_user');
gr.query();
var users = [];
while(gr.next()){
users.push(gr.getUniqueValue());
}
gs.info(users.toString());
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2024 07:27 PM
Thank you for marking my response as helpful.
As per new community feature you can mark multiple responses as correct.
Also my response was the 1st to provide you the correct solution.
If my response helped please mark it as well so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-25-2024 01:02 AM
Could you mark my response correct as well as I also provided the correct solution?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2024 07:11 AM
Hi @ObuM ,
please try below script:-
var gr = new GlideRecord('sys_user');
gr.query();
var users = [];
while(gr.next()){
users.push(gr.sys_id.toString());
}
gs.info(users);
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,
Ranjit