- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2020 01:57 AM
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
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2020 01:33 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2020 02:47 AM
on the catalog item when the user type in the path, i need the users to type it
as G:\ak\Shared01
but pass thru G:\\ak\\Shared01
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2020 03:09 AM
How are you retrieving the JSON? If you do JSON.stringify(<object>) it will insert the necessary escapes to preserve the string. You can then use JSON.parse(<object>) to access the object properties.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2020 03:32 AM
If I understood correctly, you want the user to type only single back slash, but you wanted to pass double black slashes from script?. If this is the requirement then you need to use string manipulation methods.
var str = 'value_entered_by_user';
var res = str.replace(/\//gi, "\\\\");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2020 12:48 AM
hi there
is this correct, you had gi in your code, what does it refer to?
function onSubmit() {
//Type appropriate comment here, and begin script below
var str = g_form.getValue('new_folder_path');
var res = str.replace(/\//gi, "\\\\");
g_form.setValue('new_folder_path',res);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2020 01:08 AM
gi is part of the regex. After the actual regular expression (/\//) you can add flags, g makes the regex global so it doesn't return after the first match but continues to parse the string and the i makes it case insensitive.
You can check out common regex's and test your own at various sites such as: