Getting Started with Process Builder – Part 40 (Adding a Line Break in Process Builder Formula)

Getting Started with Process Builder – Part 40 (Adding a Line Break in Process Builder Formula)

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):

While this can be solved using various automation tools like Apex or Flow, but we will Process Builder to solve the business use case. One workaround I have found is to use the Custom Label and SUBSTITUTE function in the process builder formula

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: 

  1. Creating a custom label to store (-) 
  2. Define process properties
  3. Define evaluation criteria
  4. Define process criteria
  5. Add action – update records 

Step 1: Creating a Custom Label 

  1. Click Setup.
  2. In the User Interface, type Custom Labels.
  3. Clicks on the New Custom Label button.
  4. Enter Short Description the Name will auto-populate. 
  5. Now enter the  in the Value.
  6. Click Save.

Step 2: Define Process Properties

  1. Click Setup.
  2. In the Quick Find box, type Process Builder.
  3. Select Process Builder, then click New.
  4. Name the Process and click the Tab button. The API Name will populate. 
  5. As a best practice, always input a description
  6. The process starts when A record changes.
  7. Click Save.

Step 3: Define Evaluation Criteria

  1. Click on the Add Object node to begin selecting the evaluation criteria.
  2. Select the Lead object from the dropdown list.
  3. Start the process when a record is created or edited.
  4. Click Save.

Step 4: Define Process Criteria

  1. Click the Add Criteria node to begin defining the process criteria.
  2. Name the criteria.
  3. The criteria should execute actions when the No Criteria – just execute the actions!. 
  4. Click Save.

Step 5: Add Action – Update Records

  1. Below Immediate Actions, click Add Action.
  2. For Action Type, select Update Records
  3. Name the action.
  4. Select the option Select the Lead that started your process record type. 
  5. The criteria for updating records should be No criteria  – just update the records! 
  6. Set new field values for the records you update: 
    1. Row 1:
      1. Field: Description
      2. Type: Formula
      3. Value: [Lead].FirstName &
        SUBSTITUTE($Label.NewLine, “-“,””)&
        [Lead].LastName
  7. 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.

Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!

Preferred Timing(required)

62 thoughts on “Getting Started with Process Builder – Part 40 (Adding a Line Break in Process Builder Formula)

  1. 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)

    1. 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!

  2. 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

  3. 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.

  4. 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 ?

  5. 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!

  6. 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…

    1. 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.

  7. 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.

          1. 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

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Automation Champion

Subscribe now to keep reading and get access to the full archive.

Continue reading