- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2022 10:16 AM
Requirement: I need to retrieve the list of records through Gliderecord. I used below code but it is only retrieving the first record in the list.

Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2022 10:20 AM
Hello
please change the if to while
also if you want all names like this
var arr=[];
var obj2 = new GlideRecord('cmdb_rel_ci');
obj2.addEncodedQuery('yourencodedquery');
obj.query();
while(obj.next())
{
arr.push(obj2.child.getDisplayValue());
}
gs.info('My object names'+arr.toString)
PLEASE MARK MY ANSWER CORRECT IF IT HELPS YOU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2022 10:20 AM
Hello
please change the if to while
also if you want all names like this
var arr=[];
var obj2 = new GlideRecord('cmdb_rel_ci');
obj2.addEncodedQuery('yourencodedquery');
obj.query();
while(obj.next())
{
arr.push(obj2.child.getDisplayValue());
}
gs.info('My object names'+arr.toString)
PLEASE MARK MY ANSWER CORRECT IF IT HELPS YOU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2022 10:26 AM
Hi Mohit,
I tried this way, still getting only first record in a list.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2022 10:28 AM
var obj2 = new GlideRecord('cmdb_rel_ci');
obj2.addEncodedQuery('yourencodedquery');
obj2.query();
while(obj.next())
{
arr.push(obj2.child.name.toString());
}
gs.info('My object names'+arr.toString())
try this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2022 10:36 AM
still getting one record.
