Convert carriage returns in Multiline to in Email

Home Forums General discussion Convert carriage returns in Multiline to in Email

Viewing 2 reply threads
  • Author
    Posts
    • #34378
      Jay G
      Participant

        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!

      • #34380
        Alexander Bautz
        Keymaster

          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

        • #34569
          Jay G
          Participant

            Sorry for the delay, I just got around to implementing your suggestion today.

            It worked beautifully — thank you!

        Viewing 2 reply threads
        • You must be logged in to reply to this topic.