Please explain setStringParameterNoEscape() with example.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2015 05:30 AM
An AFTER business rule is written to send SMS through REST API as written below.
function triggerSMS()
{
var r = new RESTMessage('SMS', 'get');
r.setStringParameter('mnumber',current.u_recipient_number);
r.setStringParameter('message', current.u_message);
var response = r.execute();
gs.log(current.u_recipient_number+' ,Execution Response:'+response.getBody());
}
This business rule is executing properly. But If message contains reserved character as & gets converted to equivalent escaped character as &
To avoid this issue if I write
r.setStringParameterNoEscape('message', current.u_message);
It is not working properly .
In log I got below information and I didnt receive SMS aswell.If also the message doesnt contain XML reserved character also.
How to use setStringParameterNoEscape() with example please and how to prevent & converting to & .
Its not jelly script.
Thanks in advance.
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2015 11:07 PM
Any answer?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2018 09:28 AM
Here is the solution:
Lets suppose you are trying to send contents of current.u_message:
escapedMessageToSend = new JSON().encode(current.u_message);
escapedMessageToSend = escapedMessageToSend.substring(1, escapedMessageToSend.length - 1);//remove the quotes added around the string by encode function
escapedMessageToSend = escapedMessageToSend.replace(/\\n/g, "<br>"); //depending on business logic you could replace newline characters with html br or just remove the special chars
r.setStringParameterNoEscape('message', escapedMessageToSend );
Please mark the response helpful/correct if it helps answer your question.