Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Parse Nested Array

Pavan_Snow_1
Kilo Guru

Hi all,

I am storing the Array in below format. I need Line Id value from each object.

[

{'Quantity': '4','Parent':'OR00001','Sku':'Test1','Line Id':'3.00'},

{'Quantity': '5','Parent': 'OR00001','Sku': 'Test2','Line Id': '2.00'}

]

please help how to get the Line Id details from above array.

Thanks,

Pavan

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron

Hi,

this works well

var obj = [
{'Quantity': '4','Parent':'OR00001','Sku':'Test1','Line Id':'3.00'},
{'Quantity': '5','Parent': 'OR00001','Sku': 'Test2','Line Id': '2.00'}
];

var arr = [];

for(var i=0;i<obj.length;i++)
arr.push(obj[i]['Line Id'].toString());

gs.info(arr);

Output:

find_real_file.png

Regards
Ankur

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

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron

Hi,

this works well

var obj = [
{'Quantity': '4','Parent':'OR00001','Sku':'Test1','Line Id':'3.00'},
{'Quantity': '5','Parent': 'OR00001','Sku': 'Test2','Line Id': '2.00'}
];

var arr = [];

for(var i=0;i<obj.length;i++)
arr.push(obj[i]['Line Id'].toString());

gs.info(arr);

Output:

find_real_file.png

Regards
Ankur

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

Allen Andreas
Tera Patron

Hi,

You can try this in background to see if you like it:

var array = [

{'Quantity': '4','Parent':'OR00001','Sku':'Test1','Line Id':'3.00'},

{'Quantity': '5','Parent': 'OR00001','Sku': 'Test2','Line Id': '2.00'}

];

for (var i=0;i<array.length;i++) {
gs.info(array[i]['Line Id']);
}

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!