Here is a quick little tip on how to save two strings, with a line break between them, to a text area field when you’re in Visual Flow.
Using BR() Doesn’t Work
Salesforce text formula fields allow the use of a BR() function to force a line feed in the value of the field.
For instance, if I have a formula field of “Line 1” & BR() & “Line 2” the output will be:
Visual Flow uses most of the same functions that are available in formula fields so it would make sense that BR() could be used in a flow formula. And, indeed, if BR() is used in a formula the Flow will save just fine.
Unfortunately, though, you will not get the result you want:
The workaround requires that you take one extra step, and use a different function.
The Extra Step
The extra step is to create a Text Template as follows:
- Enter a text character or string (in this example I’m using “~”)
- Tap the Enter key to go to the next line
- Enter the same character or string
The Alternate Function
The function you’ll use instead of BR() is SUBSTITUTE(). The syntax of SUBSTITUTE is:
SUBSTITUTE( WorkingString, StringToLocate, SubstitueString )
- The WorkingString is the string that the Substitute function is working on
- The StringToLocate is what you’re looking for in the WorkingString
- The SubstituteString is the value that will be place into the WorkingString in lieu of the StringToLocate
So in my example this would look like:
- SUBSTITUTE(TextTemplate, “~”, “”)
The Final Formula
So your final formula will be:
String1 & SUBSTITUTE( TextTemplate, SearchString, “”) & String2
Using the Line Break Formula
You can now use your formula to populate Text Area fields that allow for separate lines. You can also use your formula to display text in display fields in your flow screens.
Taking it One Step Further – Just For Fun
Let’s take it one step further and add a line between strings. For example, let’s say you have a description field that you’re adding information to, but you want to see a visual break between the old and new text.
Super simple to do! Just add anything to your text template that you want to be added to the final value of your formula: