- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2020 05:38 AM
Hello All,
I have a requirement to insert the value returned by multi row set(json array) to existing json in the workflow. Could you please someone guide?
var obj1 = '{"app_said":"123","app_code":"AAA","application_type":"business","business_unit":"aaa","primary_email":"p@test.com","secondary_email":"s@test.com","manager_email":"m@test.com","description":"sd"}'
var obj2 =' [ {
"s_type" : "physical",
"os" : "esx",
"f_type" : "application",
"env" : "prod",
"region" : "emea",
"a_storage" : "100",
"r_required" : "false"
} ]'
Expected output:
{"app_said":"123","app_code":"AAA","application_type":"business","business_unit":"aaa","primary_email":"p@test.com","secondary_email":"s@test.com","manager_email":"m@test.com","description":"sd", "server_request"=[ {
"s_type" : "physical",
"os" : "esx",
"f_type" : "application",
"env" : "prod",
"region" : "emea",
"a_storage" : "100",
"r_required" : "false"
} ]}
thank you
Bala
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2020 06:05 AM
Hi there,
Are the leading and trailing quotes actually in your var obj1 and obj2? If not, below already works:
var obj1 = {"app_said":"123","app_code":"AAA","application_type":"business","business_unit":"aaa","primary_email":"p@test.com","secondary_email":"s@test.com","manager_email":"m@test.com","description":"sd"};
var obj2 = [ {
"s_type" : "physical",
"os" : "esx",
"f_type" : "application",
"env" : "prod",
"region" : "emea",
"a_storage" : "100",
"r_required" : "false"
} ];
obj1.server_request = obj2;
gs.info(JSON.stringify(obj1));
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2020 06:03 AM
HI,
So basically you have to create a array and push this JSON into that array as below:
var obj1 = '{"app_said":"123","app_code":"AAA","application_type":"business","business_unit":"aaa","primary_email":"p@test.com","secondary_email":"s@test.com","manager_email":"m@test.com","description":"sd"}';
var obj2 ='[{"s_type" : "physical","os" : "esx","f_type" : "application","region" : "emea","a_storage" : "100","r_required" : "false"}]';
var arr = [];
arr.push(obj1);
gs.print(arr);
arr.push(obj2);
gs.print(arr);
OUTPUT:
2020-04-05T13:02:52.910Z: [ "{\"app_said\":\"123\",\"app_code\":\"AAA\",\"application_type\":\"business\",\"business_unit\":\"aaa\",\"primary_email\":\"p@test.com\",\"secondary_email\":\"s@test.com\",\"manager_email\":\"m@test.com\",\"description\":\"sd\"}" ] |
2020-04-05T13:02:52.910Z: [ "{\"app_said\":\"123\",\"app_code\":\"AAA\",\"application_type\":\"business\",\"business_unit\":\"aaa\",\"primary_email\":\"p@test.com\",\"secondary_email\":\"s@test.com\",\"manager_email\":\"m@test.com\",\"description\":\"sd\"}", "[{\"s_type\" : \"physical\",\"os\" : \"esx\",\"f_type\" : \"application\",\"region\" : \"emea\",\"a_storage\" : \"100\",\"r_required\" : \"false\"}]" ] |
Thanks,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2020 06:59 AM
Thanks much for the response. The other one was just worked fine. thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2020 06:05 AM
Hi there,
Are the leading and trailing quotes actually in your var obj1 and obj2? If not, below already works:
var obj1 = {"app_said":"123","app_code":"AAA","application_type":"business","business_unit":"aaa","primary_email":"p@test.com","secondary_email":"s@test.com","manager_email":"m@test.com","description":"sd"};
var obj2 = [ {
"s_type" : "physical",
"os" : "esx",
"f_type" : "application",
"env" : "prod",
"region" : "emea",
"a_storage" : "100",
"r_required" : "false"
} ];
obj1.server_request = obj2;
gs.info(JSON.stringify(obj1));
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2020 06:59 AM
thank you so much for the quick response