- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2022 06:16 AM
Hi,
I need a help for removing white spaces from Pending reason (SLA_SUSPENDED_FOR) field before sending it to third party system.
we are using RESTMessageV2 API , sending data to third party system using scheduled job and we have tried setStringParameter but that did not work for white spaces removal. we are using JSON format here.
can anyone suggest the syntax or how we can remove the white spaces in string field ?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2022 06:05 PM
Hi Jyoti,
To remove leading and trailing spaces, use .trim().
https://www.w3schools.com/jsref/jsref_trim_string.asp
If it's necessary to concatenate multiple spaces within a text into one, add the following code. Here, variable "str" is a string representing value of Pending reason.
str = str.replace(/ +/g, ' ');
To remove tabs and new lines also, use the following script instead.
str = str.replace(/\s\s+/g, ' ');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2022 06:35 AM
You can use a regex to remove all white spaces from your string before sending: .replace(/ /g,'')
var str = 'a,b,c blabla nice white space';
gs.info(str.replace(/ /g,''))​
results in : a,b,cblablanicewhitespace

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2022 06:05 PM
Hi Jyoti,
To remove leading and trailing spaces, use .trim().
https://www.w3schools.com/jsref/jsref_trim_string.asp
If it's necessary to concatenate multiple spaces within a text into one, add the following code. Here, variable "str" is a string representing value of Pending reason.
str = str.replace(/ +/g, ' ');
To remove tabs and new lines also, use the following script instead.
str = str.replace(/\s\s+/g, ' ');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2022 10:53 PM
Hi Hitoshi,
Thanks for your response! Actually I am new to Integrations and don't know exactly how to get the pending reason field value in Str field. could you please help me ?
Regards,
Jyoti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2022 11:10 PM
Thanks! it worked 🙂