3

We created a field of type "Formula" with Formula Return Type "Text" and the Advanced Formula (using the BR function):

'Line1' + BR() + 'Line2' + BR() + 'Line3'

This field was included in Compact Layout and in Page Layout. The field is sometimes (randomly (!)) displayed correctly (3 lines with line breaks, also see the first screenshot)

Line1
Line2
Line3

and sometimes as HTML markup (also see the second screenshot):

Line1<br>Line2<br>Line3

The same happens using the IMAGE function or any other function generating HTML markup.

In case of correct display, the HTML source for this snippet is

<p class="slds-text-body--regular  slds-truncate" data-aura-rendered-by="307:719;a">
    <span data-aura-rendered-by="298:719;a">
        Line1<br data-aura-rendered-by="300:719;a">Line2<br data-aura-rendered-by="300:719;a">Line3
    </span>
</p>

In case of incorrect display, the HTML source is

<p class="slds-text-body--regular  slds-truncate" data-aura-rendered-by="307:719;a">
    <span data-aura-rendered-by="298:719;a" class="uiOutputText" data-aura-class="uiOutputText">
        Line1&lt;br&gt;Line2&lt;br&gt;Line3
    </span>
</p>
  • We're using a sandbox with the Winter'18 release
  • the same happens in the production environment and
  • both in Lightning Experience and Salesforce classic
  • in all browsers

Is this a known problem? How can this be fixed?

Correct display

Incorrect display

6
  • Is it the same in all browsers? Oct 5, 2017 at 7:26
  • I think the issue is probably indeed the browser that sometimes generates the layout themselves, interpreting it as rich text and otherwise just as text - in which case you see the HTML. A possible workaround (I think) is to define a rich text field and fill it with that data :) Oct 5, 2017 at 7:32
  • @KoenCertyn In this case rich text field works, but not in case of referencing other fields (the 'TestN' strings are just to simplify the problem description). Oct 5, 2017 at 8:10
  • You can use workflow rules/PB to complete the reference to the other fields to complete the rich text field, no? Oct 5, 2017 at 8:22
  • @KoenCertyn Ok, I've to look at this workflow rules/PB functionality, currently I'm not familiar with this. Formula field is just simple to use, so if there is a solution I would prefer using formulas. Oct 5, 2017 at 8:42

1 Answer 1

2

It looks like this issue still comes up every now and then in random places.

For anybody looking for a workaround, you can create a Custom Label (say New_Line) and use it in the concerned formulas.

The value of this custom label should be as follows.

<
>

The label needs to have the dummy starting end ending characters (that is, < and >) because all leading and trailing whitespace gets removed.

This custom label can then be used in a formula field as follows.

"Line1" & MID($Label.New_Line,2,1) & "Line2" & MID($Label.New_Line,2,1) & "Line3"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .