Carriage Returns (or line breaks) for Variables in Mail Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2018 06:01 AM
I'm trying to setup a mail script that will deliver the Variables from a RITM while maintaining carriage returns that occur in the text/string type variables.
Right now when I try to apply a ".replace" which works fine for other RITM fields, the Variables do not get returned at all (the entire script just seems to fail, and nothing is returned).
Here is the piece of the mail script giving me the trouble:
{
if (vs.get(i).toString().indexOf("Text") != -1){ //equals -1 if it never occurs in the String
//creates rows from Variables
template.print('<tr>');
template.print('<td align="right" valign="top" width=50%>' + vs.get(i).getLabel() + ': ' + '</td>' + '<td align="left" valign="top" width=50%>' + ' ' + vs.get(i) + '</td>');
}
else {
template.print('<tr>');
template.print('<td align="right" valign="top" width=50%>' + vs.get(i).getLabel() + ': ' + '</td>' + '<td align="left" valign="top" width=50%>' + ' ' + vs.get(i).getDisplayValue() + '</td>');
}
The part in bold is what I've been unable to get carriage returns to work for. I have successfully used:
string_field.replace(/(\r\n|\n|\r)/g,'<br />');
(for example) to get the RITM Description to properly show carriage returns.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2018 06:05 AM
Hi
replace(/(\r\n|\n|\r)/gm,"").trim();
Try this once .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2018 07:41 AM
Tried:
template.print(vs.get(i).getDisplayValue().replace(/(\r\n|\n|\r)/gm,"").trim());
And did not work.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2018 07:47 AM
Hi
template.print(vs.get(i).getDisplayValue().replace(/(\r\n|\n|\r)/gm,"with_what_you_want_to_relace?").trim());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2018 08:00 AM