Getting Started with Process Builder – Part 3 (Automatically Clone a Record if it Meets Certain Criteria)

Getting Started with Process Builder – Part 3 (Automatically Clone a Record if it Meets Certain Criteria)

Last Updated on December 13, 2020 by Rakesh Gupta

Big Idea or Enduring Question:

How to use Process Builder to automate business scenarios that involve cloning an existing record. 

Objectives:

After reading this blog, you’ll be able to: 

  • Understanding the Record Create Process in Process Builder
  • Understanding how to clone a record by using the create record option.
  • Using a custom field to restrict the process builder to fire only once when a condition is met.
  • Using the formula in filter condition in the process.

Business Use case

Steve Cartwright is working as a System Administrator at Universal Containers (UC). He received a requirement to auto-create a new Opportunity (Similar to an old record) whenever an Opportunity is successfully closed and set the Close date for the new Opportunity to 120 days from the old opportunity’s close date.

Automation Champion Approach (I-do):

Usually, with Salesforce multiple approaches are available to solve a business requirement. Choose the ones that are simple, straightforward, and consume fewer resources. 

Similarly in this scenario, either use Apex trigger, a combination of Flow and Process Builder, or a few more.

Let’s solve this scenario using Process Builder, as this business case involves only one level of cloning. To implement deep clone (Multilevel cloning),  either Lightning Flow or Apex Programming can be used. 

Before we dive into the solution to help Steve, though, we need to first understand what is Process Builder and its components. 

The solution involves two steps.

  1. Create a checkbox field to ensure the process builder is fired only once after it meets a criteria. So, the checkbox field is used as a flag to hold a boolean value
  2. Create a record change process and use the Create record action to clone a record whenever a specified criteria is met. 

Before diving further, let me show you a diagram of a Process Flow at a high level. Please spend a few minutes to go through the following Flow diagram and understand it.

Let’s begin building this automation process.

Guided Practice (We-do):

There are 6 steps to solve Steve’s business requirement using Process Builder. We must: 

  1. Creating a checkbox
  2. Define process properties
  3. Define evaluation criteria
  4. Define process criteria
  5. Add action – create a record 
  6. Add action – update records 

Step 1: Creating a Checkbox

  1. Click Setup.
  2. In the Object Manager, type Opportunity.
  3. Select Fields & Relationships, then click New.
  4. Select Checkbox as Data Type, then click Next.
  5. Enter Field Label and click the Next button. The Field Name will populate. 
  6. As a best practice, always input a description
  7. Set the Field-level Security for profile, make sure to set this field as read-only. 
  8. Don’t add this field to the Page Layout.
  9. Click Save

PB03- create a checkbox

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.

Screen Shot 2020-05-31 at 5.49.56 PM

Step 3: Define Evaluation Criteria

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

Screen Shot 2020-05-31 at 5.52.01 PM

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 conditions are met.
  4. Set Conditions
    1. Row 1:
      1. Field: Opportunity | Stage
      2. Operator: Equals
      3. Type: Picklist
      4. Value: Closed Won
    2. Row 2:
      1. Field: Opportunity | One Time Activity
      2. Operator: Equals
      3. Type: Boolean
      4. Value: False
  5. Select All of the conditions are met (AND)
  6. Click Save.

PB - Blog 3.3

Step 5: Add Action – Create a Record

  1. Below Immediate Actions, click Add Action.
  2. For Action Type, select Create a Record
  3. Name the action.
  4. Select the Opportunity record type. 
  5. Set Field Values:
    1. Row 1:
      1. Field: Close Date
      2. Type: Formula
      3. Value: [Opportunity].CloseDate + 120
    2. Click Add Row
    3. Row 2:
      1. Field: Name
      2. Type: Formula
      3. Value: [Opportunity].Name +” + “
    4. Click Add Row
    5. Row 3:
      1. Field: Stage
      2. Type: Picklist
      3. Value: Prospecting
    6. Click Add Row
    7. Row 4:
      1. Field: Forecast Category
      2. Type: Picklist
      3. Value: Pipeline
  6. Click Save.

Screen Shot 2020-05-31 at 6.03.52 PM

Step 6: 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 Opportunity record that started your process record type. 
  5. Criteria for Updating Records: No criteria – just update the records! 
  6. Set Field Values:
    1. Field: One Time Activity
    2. Type: Boolean
    3. Value: True
  7. Click Save.

Screen Shot 2020-05-31 at 6.13.40 PM

Almost there! Once everything looks good, click the Activate button.

Now onwards, a new opportunity will be automatically created whenever (only once) an opportunity is updated as Closed Won. 

Note:- Before you activate your process, you have to make sure that you have assigned data in the correct format because Process Builder obeys validation rules. If some fields are required by using validation rules, then make sure you have added those fields. Conversely, if some fields are required on the page layout, you can ignore those fields. 

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!

19 thoughts on “Getting Started with Process Builder – Part 3 (Automatically Clone a Record if it Meets Certain Criteria)

  1. Hi Rakesh, love the blog.

    Would you mind please explaining the logic behind the
    Value: [Opportunity].Name +” + “ formula for the New Opportunity Name?

    Could it also make sense to use Value: [Opportunity].Name + Renewal?

    I do not understand the use of + and “.

    Thanks,
    Eric

  2. What if we keep closedate as “Closed-Won” other than “Prospecting” on our clone opportunity in process builder. What happens then ?
    Salesforce is going to create more and more opportunities. If happens how can we stop it ? What are the limitations ?

    Thanks for the amazing blog…..Cheers

  3. Hi Rakesh,

    I didn’t create formula field on Opportunity object, Instead I have done this process following way and it’s working fine.
    Under Immediate Action
    Field = Close Date
    Type = Formula
    Value = : [Opportunity].CloseDate + 120.

  4. So it is not truly a clone, but just a creation of a new Opportunity. Same with a Flow, if you want a true clone you’ll have to list out all the fields you want included in Step 7?

  5. Thank you so much for this post. I’ve used it to change the record type on a cloned custom object. I was able to change the Record Type field, but how can I make other field “re-set” to blank? I thought it would be $GlobalConstant.Null, but that is incorrect. Thank you for you help!

    1. You have few options

      1. Use $GlobalConstant.EmptyString
      2. Use a Variable with empty string and refer it
      3. Create a Formula field with empty string then use it
      4. Refer the field in Record Create element and don’t enter anything against it
  6. This is great!! Only questions – when I try this, the cloned opp does not take the Account name, is there anything I have to do differently to accomplish that?

  7. Rakesh –

    I think now we can clone the Opportunity and set the closed date on the cloned opportunity by using formula : [Opportunity].CloseDate + 120. No need to create any additional field in Opportunity object. The above use case I have tried on my developer org without using any additional field and it is working fine now.

    Regards,
    Sudipta Deb

  8. Rakesh,

    Thank, great articles. Regarding multilevel cloning in process builder, could I use multiple sequential time initiated clones, with a counter field, to stop the sequencing when needed, to effect the result of multilevel cloning in apex?

    Thanks
    Pete

  9. Rakesh, when creating a record can you merge text+field data?

    For example in your step 7. is it possible to push a value into a field such as:
    ” The close date is: [Opportunity].X120_After_RCD__c ”

    I tried the usual notation with curly braces like: {!Opportunity.X120_After_RCD__c}
    but got an invalid reference error and couldn’t save.

    TIA

    Brian

  10. Thanks, Rakesh! Question on Step 7 – why is the fourth field for “Set Object Variables” a picklist of fields, i.e “Forecast Category”, etc.?

    Best.
    Brooks

  11. Good one. I have some doubts around “one time activity” field. Can’t we just avoid it and have an evaluation criteria which says execute only if the stage is changed to “closed won”?

Leave a Reply

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