IT Process Automation

  • 1.  Respect the new lines in HTML email

    Posted Apr 24, 2015 09:34 AM

    Hi all,

     

    I have a process that send an HTML email with some fixed tags and some variables. Some of those variables are introduced by the users with new lines but those new lines are not reflected in the email.

    How can I escape de HTML in the variables?

     

    Regards,

    Sergio Castro



  • 2.  Re: Respect the new lines in HTML email

    Broadcom Employee
    Posted Apr 24, 2015 09:47 AM

    If you just need to escape a literal string please see The Escape Character in Literal Strings in the Content Designer Guide Release 04.2.00

     

    You can use the escape character (\) in literal strings. Instead of being parsed by the CA Process Automation language interpreter, the character you enter after the escape character is interpreted literally. If a semantic action is attached to an escape character, the interpreter converts the action to its character equivalent rather than performing the semantic action.

    For example, say that you want to include a double quotation mark character within a string delimited by double quotation marks. Precede your quotation character with the escape character, so that the parser does not interpret it as the string delimiter:

    \" 

    To include the backslash character in a string, precede it with the escape character:

    \\ 

     

     

     

     

    You can find additional info about special characters in PAM this knowledge doc: TEC1707193 "Special Characters in Process Automation"



  • 3.  Re: Respect the new lines in HTML email

    Posted Apr 24, 2015 10:14 AM

    Hi MWNiebuhr,

     

    First of all, thank you for your time.

     

    This is not my problem, I know how to escape characters into static strings. My problem is with varibales.

    For example. Imagine that I want to send an HTML email with the follow description:

    Process.desc = "<b>Name:</b> " + Process.name;

    Where Process.name is a value introduced by the user and that have new lines.

     

    Regards,

    Sergio Castro



  • 4.  Re: Respect the new lines in HTML email

    Broadcom Employee
    Posted Apr 24, 2015 10:29 AM

    Not sure I understand, you would like the email to be formatted something like:

    Process_01

     

    This is line 1.

    This is line 2.

     

    Are you using the <br> tag?

     

    How are you attempting this and what is going wrong?



  • 5.  Re: Respect the new lines in HTML email

    Posted Apr 24, 2015 10:37 AM

    Yes MWNiebuhr, the email should be formatted like that but the value

    "This is line 1.

    This is line 2."

    is introduced in a IRF by the user. For me this value is a variable and I don't know where are the new lines and even if they exists, so I can't use <br> tag.



  • 6.  Re: Respect the new lines in HTML email

    Broadcom Employee
    Posted Apr 24, 2015 10:55 AM

    So someone enters into a Form:

    "This is line 1.

    This is line 2."

     

     

    But you end up with

    "This is line 1. This is line 2."  ?



  • 7.  Re: Respect the new lines in HTML email

    Posted Apr 24, 2015 11:05 AM

    Yes. This happens because my email is sent in HTML format.



  • 8.  Re: Respect the new lines in HTML email

    Posted May 22, 2015 02:25 PM

    You could also just use <pre> tags -

     

    The content of a PRE element respects line breaks and most special characters, excepting '<' and '>'

     

    This also protects you from needing to escape most special characters.

     

    You may wish to apply some in-line style: attributes to the <pre> for aesthetic purposes.



  • 9.  Re: Respect the new lines in HTML email
    Best Answer

    Broadcom Employee
    Posted May 14, 2015 11:48 AM

    A team mate of mine figured this out.

     

    Between the IRF and the Send Email operator he added a Javascript operator with the following:

     

           Process.htmldata=Process.data.replace(/\n|\r\n|\r/g, '<br/>');

     

     

    Where Process.htmldata will be the variable you use in the email and Process.data is the value coming from the form.

     

    This could be added to pre or post execution code as well.