Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

why array printing one number multiple times instead of printing every record number under query??

KM SN
Tera Expert

var abc = [];
var gr = new GlideRecord('incident');
gr.addEncodedQuery('caller_id=77ad8176731313005754660c4cf6a7de');
gr.query();


while(gr.next()){


abc.push(gr.number);
}
gs.print(abc);

ManiHouse1_0-1715074227931.png

can anyone give me explanation in laymen terms??

 

 

5 REPLIES 5

Not applicable

Hi @KM SN ,

I tried your problem in my PDI and it works for me please check below 

var abc = [];
var gr = new GlideRecord('incident');
gr.addEncodedQuery('caller_id=77ad8176731313005754660c4cf6a7de');
gr.query();
while(gr.next()){
abc.push(gr.number.toString());
}
gs.print(abc);

Result

SarthakKashyap_0-1715075908359.png

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards 

Sarthak