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. After this was published SF cleared up the encode text error and you can now use BR() again. One thing to note (though perhaps obvious) is that the target field of the update must be a text area field not a regular text field, as the latter doesn’t accommodate 2 lines.

    As far Laura’s question, Rich Text fields often don’t behave nice on text updates. I’ve gotten around its issues with creating a duplicate non-rich text field that references it and performing the update on the latter.

  2. Any idea if this behaves differently when inserting into a Rich-Text field? I have used this solution before and it worked but I just tried to re-use it just now and it’s not working.

  3. I know this is likely a silly question, but how would this work if I’m using to create a task and I want the description to have the carriage return?

    I’m not quite understanding how the formula would work since I’m not relying on fields, instead plain text. My initial thought would be something along the lines of:

    STRING(TEXT(“Text”)) &
    SUBSTITUTE($LABEL.NewLine, “-“, “”) &
    STRING(TEXT(“More Text”))

    But that doesn’t seem to work.

    Also tried:
    TEXT(“Text”) &
    SUBSTITUTE($LABEL.NewLine, “-“, “”) &
    TEXT(“More Text”)

    and:
    “Text” &
    SUBSTITUTE($LABEL.NewLine, “-“, “”) &
    “More Text”

    I’m sure it’s something simple (I hope).

    1. Travis…I was able to use the workaround to add line breaks when creating a task via Process Builder. Here is the formula that I used when setting the content of the Description field.

    2. “Update the following project fields on the portal’s project page for project ” +
      [Project2__c].Name + “: ” +
      substitute($Label.NewLine,”-“,””) +
      if(ISCHANGED([Project2__c].Project_Title__c ) ,”Title”,””) + substitute($Label.NewLine,”-“,””) +
      if(ISCHANGED([Project2__c].Abstract__c ) ,”Abstract”,””) + substitute($Label.NewLine,”-“,””) +
      if(ISCHANGED([Project2__c].Impacts__c ) ,”Impacts”,””)

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