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.

length of an array

Prasanthi1
Giga Contributor

while executing the below, I am not getting the length of list.

var inc = new GlideRecord('incident');
inc.addActiveQuery();
inc.query();
inc.next();
var list = inc.getElements()
gs.print(list.length);

showing output: undefined

why? please explain..

1 ACCEPTED SOLUTION

Seems the docs has incorrect information.

I tried the script from docs to get the length but it failed

We need to convert that to Array and then get the length

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

10 REPLIES 10

Seems the docs has incorrect information.

I tried the script from docs to get the length but it failed

We need to convert that to Array and then get the length

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader