Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to retrieve the list of records through gliderecord?

Not applicable

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.

1 ACCEPTED SOLUTION

Mohith Devatte
Tera Sage
Tera Sage

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

View solution in original post

10 REPLIES 10

Not applicable

Hi,

I have defined sysid2 in my actual code.

i also tried declaring 'names' as array outside of while loop and kept 'return' outside of while loop.

...still getting only one record.