1

I hav a flow that fetches data from a custom long text area field and populates its values in the contentnote.

I have used HTMLEncode() in my flowformula so that it includes any spl characters in the long text area field.

My issue is the flow is not capturing 'Enter keys' or line breaks that i have added in the custom long text area field . it displays as a one complete line in the contentnote...PLzzz help

Just onemore qn..I need to display a particular Text Template content as coloured font or highlighted/underlined format in my contentnote record. The issue is i tried using tag and all that displays a flow exception when i try to save the record

enter image description here

  • 1
    please ask a new question using the Ask Question not by editing your previous question. As this question has an accepted answer it is unlikely anyone would look at answering your new question. – Dave Humm Sep 6 '17 at 12:03
1

I think if you put this in a formula in your flow it should work for you:

SUBSTITUTE( JSENCODE( {!fieldname} ) , '\r\n', '<br>')

The substitute function simply replaces the new line character '\r\n' with the tag you need <br>. The JSENCODE encodes your field as save for javascript. I don't think that should be necessary, but without it the formula won't recognize the line breaks. (I tried something like 12 different forms of line break, and got none of them to be recognized by the substitute function.

Edit: @horzel_evh provides some interesting insights in a separate answer. He/she points out that line breaks can be stored as \r\n or as \n. I thought Salesforce would store all the \n as \r\n but I just tried and it doesn't. The following formula would therfore be more robust:

SUBSTITUTE( SUBSTITUTE( JSENCODE( {!fieldname} ), '\r\n', '<br>'), '\n', '<br>')
  • The solution works perfectly fine..Just a little issue i faced was JSENCODE did not escape spl characters..so i used JSINHTMLENCODE in ur formula Thanks!. – Meena Sep 6 '17 at 8:25
1

I am not yet able to comment on Kaspers post, so I do provide a new answer.

Depending on how data gets updated in Salesforce, a break might consist of either an carriage return, and a line break, or just the line break .

So suggest to update to: SUBSTITUTE( JSENCODE( {!fieldname} ) , '\r?\n', '
')

Reference: Common REGEX Validation

  • Thanks Much.I have used Kaspers formula and it seems to be working as per my comments! – Meena Sep 6 '17 at 11:49
  • Hi Meena, if it works for you, great! Data Loader for example will only allow you to upload a newline (\n), not a Carriage Return(\r), so just keep that in your mind. – horzel_evh Sep 6 '17 at 12:14
  • @horzel_evh Welcome to Salesforce stack exchange. You have a very good point. I though all the \n where automatically converted to \r\n but I tried, and you are right. I changed my answer to include your insights. I didn't use the '\r?\n' because the substitute function doesn't use regex but just plain text replacement. That might be why it wouldn't find the line breaks without the jsencode function. Thank you for your insights! – Kasper Sep 6 '17 at 12:23
  • 1
    TXS @Kasper for the follow up! – horzel_evh Sep 6 '17 at 19:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.