REST OUTBOUND MESSAGE JSON FORMAT - ESCAPE CHARACTER BACKSLASH

levino
Giga Guru

Hi There

REST OUTBOUND MESSAGE JSON FORMAT to mid server to runbook

 

i am trying to pass a 

value parameter FolderPath = G:\ak\shared18

it works if the user type in

G:\\ak\\shared18

i still want the user to  type in G:\ak\shared18, is there a way around this

 

do i modify the outbound message to pass thru a escape character

 

Thanks

Levino

1 ACCEPTED SOLUTION

levino
Giga Guru

all sorted , i have used a onload script

View solution in original post

30 REPLIES 30

@ServiceNow User ,

if that is an object format then you can do something like below.

var str = {'short_description': '<text>','description': {'status':'<status>', 'priority':'<priority>','source':'<source>' }}
gs.print (str.description.status);

if it is in a string format then you need to convert into an object and then use dot notation to go through nested object.

var str = "{'short_description': '<text>','description': {'status':'<status>', 'priority':'<priority>','source':'<source>' }}"
str = JSON.parse(str);
gs.print (str.description.status);
 

Thanks, i just need to pass the value to a Runbook 

the variable 'new_folder_path' value in format  G:\ak\shared01

levino
Giga Guru

The user types in the Folder path on the UI , the user will be only typing in a single backslash

 

but i need to pass to the HTTP Method a double back slash becoz of JSON escape character

 

HTTP method 

 

{
"Name": "Folder Path (e.g. 'G:\\ak\\Shared01'",
"Value": "${FolderPath}"
},
{

Yes, as we are updating the variable by adding double black slashes, It should work. To make things easier, can you post the workflow screenshots?

levino
Giga Guru