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.

Parse data in Multi row variable set

Kumar38
Kilo Sage

I have a multi row variable set and I need to copy over the data into multi line text to present data to user on Tasks.

How do I parse the below to get data as AIX,BIX,CIX

 

[{"vr_table_names_2":"AIX"},{"vr_table_names_2":"BIX"},{"vr_table_names_2":"CIX"}]

 

1 ACCEPTED SOLUTION

Allen Andreas
Tera Patron

Hi,

Ideally, we'd love to see what you've attempted thus far, so we can help you learn, but...

If what you're getting is what you've shown, then you can use something like to this get the data formatted as you need:

var array = [];
var obj = [{"vr_table_names_2":"AIX"},{"vr_table_names_2":"BIX"},{"vr_table_names_2":"CIX"}];
for (var i = 0; i < obj.length; i++) {
array.push(obj[i].vr_table_names_2);
}
gs.info(array.toString()); //or just array if you want it in array format

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


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

View solution in original post

3 REPLIES 3

Allen Andreas
Tera Patron

Hi,

Ideally, we'd love to see what you've attempted thus far, so we can help you learn, but...

If what you're getting is what you've shown, then you can use something like to this get the data formatted as you need:

var array = [];
var obj = [{"vr_table_names_2":"AIX"},{"vr_table_names_2":"BIX"},{"vr_table_names_2":"CIX"}];
for (var i = 0; i < obj.length; i++) {
array.push(obj[i].vr_table_names_2);
}
gs.info(array.toString()); //or just array if you want it in array format

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


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

Thanks , I missed obj[i] in my code

array.push(obj[i].vr_table_names_2);

Hi,

We wouldn't know as you didn't share it. In the future, please also share what you have, etc. so we can help you learn.

Glad you're good to go now though! 🙂

Take care!


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