Convert carriage returns in Multiline to in Email
- This topic has 3 replies, 2 voices, and was last updated 5 years, 1 month ago by .
Viewing 2 reply threads
Viewing 2 reply threads
- You must be logged in to reply to this topic.
Home › Forums › General discussion › Convert carriage returns in Multiline to in Email
Hi all! I just started on my journey using DFFS about 3 months ago and loving it.
This came up on one of my solutions: is there a way to change carriage returns from a multiline into <br>’s in an HTML email?
Multiline Entered:
This is an example
– Item 1
– Item 2
Comes thru email as:
This is an example – Item 1 -Item 2
Thank you!
Hi,
Yes, you can fix this by using some custom js. Start by adding this to your Custom JS:
// Define the variable outside the function to make it available globally
var multilineEmailVariable = "";
function dffs_PreSaveAction() {
// Update the value when saving - before the email is processed
multilineEmailVariable = getFieldValue("Your_multiline_field").split("\n").join("<br>");
// This function must return true to save the form
return true;
}
Replace Your_multiline_field with your actual field name.
Now change your email template to use the variable like this:
{var:multilineEmailVariable}
Let me know how it works out.
Alexander
Sorry for the delay, I just got around to implementing your suggestion today.
It worked beautifully — thank you!
Thanks for the feedback.
Alexander