Last Updated on November 24, 2020 by Rakesh Gupta
Big Idea or Enduring Question:
There is a formula function called BR() that allows us to insert a line break into text formula expressions or string of text, As shown in the following screenshot:
The expected result in the formula field is:
LastName
FirstName
But you will get the actual result similar to the following line because of the known issue (https://success.salesforce.com/issues_view?id=a1p300000008YkZAAU)
LastName_BR_ENCODED_FirstName_BR_ENCODED_
Objectives:
After reading this blog post, the reader will be able to:
- How to write a formula in process builder to add a line break
Business Use Case
Pamela Kline is working as a System administrator at Universal Containers (UC). She wants to update the Lead’s Description field with Lead’s Last Name in the next line of Lead’s First Name.
Automation Champion Approach (I-do):
Let’s begin building this automation process.
Guided Practice (We-do):
There are 5 steps to solve Pamela’s business requirement using Lightning Flow. We must:
- Creating a custom label to store (-)
- Define process properties
- Define evaluation criteria
- Define process criteria
- Add action – update records
Step 1: Creating a Custom Label
- Click Setup.
- In the User Interface, type Custom Labels.
- Clicks on the New Custom Label button.
- Enter Short Description the Name will auto-populate.
- Now enter the — in the Value.
- Click Save.
Step 2: Define Process Properties
- Click Setup.
- In the Quick Find box, type Process Builder.
- Select Process Builder, then click New.
- Name the Process and click the Tab button. The API Name will populate.
- As a best practice, always input a description.
- The process starts when A record changes.
- Click Save.
Step 3: Define Evaluation Criteria
- Click on the Add Object node to begin selecting the evaluation criteria.
- Select the Lead object from the dropdown list.
- Start the process when a record is created or edited.
- Click Save.
Step 4: Define Process Criteria
- Click the Add Criteria node to begin defining the process criteria.
- Name the criteria.
- The criteria should execute actions when the No Criteria – just execute the actions!.
- Click Save.
Step 5: Add Action – Update Records
- Below Immediate Actions, click Add Action.
- For Action Type, select Update Records.
- Name the action.
- Select the option Select the Lead that started your process record type.
- The criteria for updating records should be No criteria – just update the records!
- Set new field values for the records you update:
- Row 1:
- Field: Description
- Type: Formula
- Value: [Lead].FirstName &
SUBSTITUTE($Label.NewLine, “-“,””)&
[Lead].LastName
- Row 1:
- Click Save.
Almost there! Once everything looks good, click the Activate button.
Don’t forget to active the Process by clicking on the Activate button.
Proof of concept
Now onwards, if a business user updates the Lead, Process Builder will automatically populate the description with First Name and Last Name field.
Formative Assessment:
I want to hear from you!
What is one thing you learned from this post? How do you envision applying this new knowledge in the real world?
Let me know by Tweeting me at @automationchamp, or find me on LinkedIn.
Thanks a lot! Worked perfectly!
Elegant solution to a nagging issue! Thanks for sharing
I am glad this was useful!
This is terrific, thanks Rakesh!
I am glad this was useful!
How would you use this to substitute +BR()+ in a formula that is combining a selection of values from a multi-select picklist?
IF(INCLUDES([zqu__Quote__c].Additional_Standard_Terms__c, “A”),
“A’s definition.”, NULL) +BR()+
IF(INCLUDES([zqu__Quote__c].Additional_Standard_Terms__c, “B”),
“B’s definition.”, NULL) +BR()+
IF(INCLUDES([zqu__Quote__c].Additional_Standard_Terms__c,”C”),
“C’s definition.”, NULL)
I answered my own question and got it to work:
IF(INCLUDES([zqu__Quote__c].Additional_Standard_Terms__c, “A”), “A’s definition”, NULL)
+ SUBSTITUTE($Label.LineBreak , “-“, “”) +
IF(INCLUDES([zqu__Quote__c].Additional_Standard_Terms__c, “B”), “B’s definition.”,NULL)
+ SUBSTITUTE($Label.LineBreak , “-“, “”) +
IF(INCLUDES([zqu__Quote__c].Additional_Standard_Terms__c,”C”), “C’s definition.”, NULL)
But now I have a NEW PROBLEM:
How (can?) you use this for a single block of text too? Meaning I need “A’s definition” to be a two paragraphs separated by a line break.
EX:
When the value of “A” is selected from the list, return this text exactly:
“First paragraph of words and definitions. With another sentence here.
Followed by this paragrah of words, sentence, etc….”
Thanks!
Like it, like it alot! Thanks so much! How long did it take you come up with that!?
Got it working, it was to do with the field type. Thanks!
🙂
It is not working for me. I have used hypen(-) in the custom label and substitute formula. Not sure what I am missing here.Can any one help?
Fantastic workaround, thank you!
🙂
THANK YOU, THANK YOU, THANK YOU
🙂 🍾🎉🎉
Worked like a charm. Thank you very much for posting awesome automation stuff for admins.
Nice! Thanks!
🙂
Works perfectly – thank you!!
🙂
Thanks because you save a lot of time of me.Please create any integration post for beginners because So,Many of my friends while doing trailhead facing so may problems.It’s so difficult to understand
Rakesh this is fantastic! Thank you greatly! Appreciate what you do for the community.
Thanks for your kind words Nathan!
Great work, Rakesh, and thanks for sharing with those of us who really want pretty carriage returns! It worked like a charm. For those of you who might still be getting errors, make sure you are zooming in on the pictures so you get the spelling/syntax just right. And if you correct an error in your formula field, make sure you click the button before clicking for the Immediate Action. I occasionally forget to use the button and it wipes out your updates.
Thank you!!!
Many thanks for this hack! You just helped to make an ugly description field pretty again!
This is great — it works..thanks a lot 🙂
This is great – but does not work on a Rich Text field.:(
Wel done Rakesh, working smoothly. Thx for this post
🙂
This is the hack of the century!
Lol Thank you!
BRILLIANT! Thank you!
🙂
Thanks Rakesh, nice post. this is working for us — however when we are trying to deploy this process builder onto higher sandbox – this $Label.Next_Line is giving error … any thoughts ? is this sfdc restriction ?
You have to move Label first
This is amazing!!! Thank you so much! I was banging my head on the desk about the BR() issue.
🙂
This is brilliant. Thank you for sharing 🙂
🙂
can we use custom label as a list.It means how list works
I think yes we can use Custom Label using Flow
Worked like a champ! The BR() issue with ProcessBuilder formulas is a shortcoming for Salesforce – I had been scratching my head for a while to get around it. This works!
🙂
When I press save PB changes my formula from “Text” & SUBSTITUTE($Label.NewLine, “-“, “”) & “Text” to “Text” & br() & “Text” and the same _BR_Encoded appear in my text field…
Hi Isan,
I am facing a similar issue when trying to save the formula itself converts to Substitute function to BR.
Were you able to resolve this.
This isn’t quite working for me. When you create the custom label, are you indicating use of hyphens (-) or underscores (_) ? I tried both, and both show up in the final field. A carriage return does result between them, but I don’t want to still have the hyphens or underscores.
Include
– (hyphen)
– (hyphen)
Tried that, it resulted in hyphens showing (with a carriage return in between).
Please verify your formula
Hi,
I think the issue is the type of field. I’m can’t get it to work on a Rich Text Area field field but a Long Text Area this solution works great.
Hope this helps.
Kind Regards