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.

Passing MRVS in JSON through script API in ServiceNow Flow designer

User205031
Tera Contributor

Hi All,

I have a catalog form with 1 variable set and passing 2 values:

User205031_0-1750751894774.png

 

The payload JSON looks like this:

 

{
"extra_vars":{
"ticket": "<input>",
"tenant_id": "<input>",
"tenant_name": "<input>",
"snmp": "[{\"snmp_comp\":\"test\",\"site\":\"test\"},{\"snmp_comp\":\"test1\",\"site\":\"test1\}]"
}
}

 

How can I make the payload JSON to look like this?

 

{
"extra_vars": {
   "ticket""<string>",
   "tenant_id""<string>",
   "tenant_name""<string>",
   "snmp"[{"snmp_comp":"test" , "site":"test"},{"snmp_comp":"test1" , "site":"test1}]
   ]
 }
}

I want to change the highlighted text.

I don't want to show "snmp" attribute values within " " and should not contain any "\".

 

Is that possible? or "snmp": "[{\"snmp_comp\":\"test\",\"site\":\"test\"},{\"snmp_comp\":\"test1\",\"site\":\"test1\}]" -> this is the correct JSON format we are receiving?

 

Please let me know!

Thanks!

 

1 ACCEPTED SOLUTION

Chaitanya ILCR
Mega Patron

Hi @User205031 ,

 

use JSON.parse to convert it from

"[{\"snmp_comp\":\"test\",\"site\":\"test\"},{\"snmp_comp\":\"test1\",\"site\":\"test1\}]"

to  [{"snmp_comp":"test" , "site":"test"},{"snmp_comp":"test1" , "site":"test1}]

 

use inline script or do that

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

View solution in original post

2 REPLIES 2

Chaitanya ILCR
Mega Patron

Hi @User205031 ,

 

use JSON.parse to convert it from

"[{\"snmp_comp\":\"test\",\"site\":\"test\"},{\"snmp_comp\":\"test1\",\"site\":\"test1\}]"

to  [{"snmp_comp":"test" , "site":"test"},{"snmp_comp":"test1" , "site":"test1}]

 

use inline script or do that

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

Hi @Chaitanya ILCR ,

 

It worked.

 

Thanks!