Indexing in Glide Record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2017 05:16 AM
Hi All,
I was working on a script, and I am facing difficulties in looping through the result set. PFB code
var stageUsers = GlideRecord('sys_user');
stageUsers.addQuery('u_first_name','CONTAINS','test');
stageUsers.query();
var userArray = [];
while(stageUsers.next()) {
gs.log(stageUsers.u_first_name);
userArray.push(stageUsers.u_first_name);
}
Assuming 5 users match the criteria: TestUser1,TestUser2,TestUser3,TestUser4,TestUser5
gs.log is printing these 5 users. However, userArray is having 5 entries of TestUser1.
Any idea on how to index the results?
We can save the result to a variable, split it and assign it to an array. But I need to know if we have any method in JavaScript \ ServiceNow OOTB.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2017 01:48 PM
I hope this helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2018 08:53 AM
Hi gowthams1024, I just noticed that this thread is still not marked as answered. Would you mind selecting one of the responses as correct so that we can set it to answered?
Thanks,
Berny