Getting Started with Process Builder – Part 7 (Auto Create and Activate a Contract )

Getting Started with Process Builder – Part 7 (Auto Create and Activate a Contract )

Last Updated on December 15, 2020 by Rakesh Gupta

Big Idea or Enduring Question:

How do you create and activate a contract using Process Builder?

Objectives:

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

  • Learn how to create a contract using Process Builder
  • Learn how to auto-activate a contract

Business Use case

Tamara McCleary is working as a System Administrator at Universal Containers (UC). At UC they are using Salesforce to manage their Contracts. Salesforce allows you to create a Contract for an Account. Whenever an Opportunity is successfully closed (Stage: – Closed Won), auto-create a new Contract and activate it. Also, set the Contract Start Date = Close date of current Opportunity and Contract Term (months) = 12.

Automation Champion Approach (I-do):

Contract management is the management of contracts made with customers, vendors, or partners. Salesforce also allows you to manage contracts. This article helps you to understand how to auto-create and activate a contract using Process Builder, and how to build a Process that will only fire Whenever a record is created, and any time it’s edited to subsequently meet criteria. Let’s start with a business use case. 

There are multiple ways to solve the above business requirement. You can either use Apex trigger, Combination of Flow & Process Builder, and more. To solve this requirement, we will use the Process Builder.  Before starting the Implementation,  you have to understand one important concept related to contract management — Salesforce doesn’t allow you to insert a Contract with Status = Activated (Either through Data Loader, Workflow Rule, or Process Builder), if you attempt to do so you will get an error. In other words, we can say, it is not possible to insert and activate Contracts in a single step. Contracts must first be added with a Status of Draft, and then after inserting, they can then be updated with a status of Activated. Follow the below instructions to create a Process for the above business requirement. 

There are four basic components that should be considered when using Process Builder —  a trigger, criteria, immediate action, and scheduled action.

Component Process
Trigger Indicates when the action should fire – only when a record is created or anytime a record is created or edited
Criteria Set conditions to execute the process
Immediate Action The action is fired immediately
Scheduled Action The action is fired at a scheduled time

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 3 steps to solve Tamara’s business requirement using Process Builder. We must: 

  1. Create a custom field on the Contract object
  2. Process Builder 1
    1. Define process properties
    2. Define evaluation criteria
    3. Define process criteria
    4. Add action – create a record 
  3. Process Builder 2
    1. Define process properties
    2. Define evaluation criteria
    3. Define process criteria
    4. Add action – update records

Step 1: Create a Custom Field on Contract Object 

Create a checkbox field Contract – Opportunity (Default value: – Unchecked) on the Contract object so that Process Builder will fire and activate only those contracts which get created after the successful closure of an Opportunity. Don’t add this field to the Contract Page Layout.

  1. Click Setup.
  2. In the Object Manager, type Contract.
  3. Select Fields & relationships, then click New.
  4. Select Checkbox as a Data Type then clicks Next.
  5. Field Label the FIeld, API Name will populate and click the Next button.
  6. As a best practice, always input a description
  7. Click Save.

Custom field on Contract object

Process Builder 1

Step 2.1: 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 2.2: 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.

Step 2.3: 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
  5. Click Add Row
    1. Row 2
      1. Field: Opportunity | Account ID
      2. Operator: Is Null
      3. Type: Boolean
      4. Value: False
  6. Select All of the conditions are met (AND)
  7. Click Advanced
  8. Select Yes to execute the actions only when specified changes are made to the record.
  9. Click Save.

The reason why we would select the Yes checkbox for the question — Do you want to execute the actions only when specified changes are made to the record? — is to allow the Process Builder to execute the actions only if the record meets the criteria now, but the values that the record had immediately before it was saved didn’t meet criteria. This means that these actions won’t be executed when irrelevant changes are made.

Step 2.4: 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 Contract record type. 
  5. Set Field Values:
    1. Row 1:
      1. Field: Account ID
      2. Type: Field Reference
      3. Value: Opportunity | Account ID
    2. Click Add Row
    3. Row 2:
      1. Field: Contract Term
      2. Type: Number
      3. Value: 12
    4. Click Add Row
    5. Row 3:
      1. Field: Contract – Opportunity
      2. Type: Boolean
      3. Value: True 
    6. Click Add Row
    7. Row 4:
      1. Field: Contract Start Date
      2. Type: Field Reference
      3. Value: Opportunity | Close Date 
    8. Click Add Row
    9. Row 5:
      1. Field: Status
      2. Type: Picklist
      3. Value: Draft 
  6. Click Save.

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

Once you are done with process activation, click on the View all Processes button. It will redirect you to the Process Management page. We will now begin to build Process 2.

Process Builder 2

Now we need to create a new Process on the Contract object to activate the contract, which gets created after the successful closure of an Opportunity (By Process 1).

Step 3.1: Define Process Properties

  1. Click Setup.
  2. Name the Process and click the Tab button. The API Name will populate. 
  3. As a best practice, always input a description
  4. The process starts when A record changes.
  5. Click Save.

Step 3.2: Define Evaluation Criteria

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

Step 3.3: 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: Contract | Contract – Oportunity 
      2. Operator: Equals
      3. Type: Boolean
      4. Value: True 
  5. Select All of the conditions are met (AND)
  6. Click Save.

Step 3.4: 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 Contract record type. 
  5. Select No Criteria – just update the records! 
  6. Set Field Values:
    1. Row 1:
      1. Field: Status
      2. Type: Picklist
      3. Value: Activated 
  7. Click Save.

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

 

Note:- Before you activate your process, you will want 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. 

Proof of Concept

Now onwards if a business user updates the Opportunity Status to Closed Won, Process Builder will automatically create a new Contract and activate it. It’s time to test out the process.

  1. Existing Opportunity – Stage Qualification
    1. Currently, Opportunity “Edge Emergency Generator” is in the Qualification Stage.
  2. Opportunity Stage After Update
    1. Now we will try to update the Opportunity “Edge Emergency Generator” Stage to Closed Won.
  3. New Contract (Status – Activated)
    1. Once you are done, click on the Save button and check the Contract created by Process Builder.

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.

Author: - Rakesh Gupta
Technical Editor: - Frances Barrera
Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!

11 thoughts on “Getting Started with Process Builder – Part 7 (Auto Create and Activate a Contract )

  1. Hi Rakesh is it not possible to place contract activation logic in another action instead of creating a new process?
    Once contract record is created in Draft , in another action we can activate it right??

      1. Hi Rakesh,

        I have made a small change and try to figure out what we can do now in this scenario?

        I have merged both process builder. by creating one more action in first process.

        first time it works great when opportunity get closed won.[result = it create a contract and activate it]

        now what i did here => i cloned the contract and create 4 new contract with draft status.

        i changed the status field of same opportunity and again set to closed won.

        NOW I SURPRISED ==> all contracts get activated; [ I hope that only the newly created contract will get update]

        can you please help me if I want to update only the new contract then what should I do?

        1. I need some time to think – but the best possible solution is to use Flow – Where Record Lookup element will allow you to sort the record based on CreatedDate or any field.

  2. Thank you Rakesh, this was just about spot on for a process I needed to build out. If I wanted to go a bit further and have a Contract Payment record created for each month of the term is that something I can achieve with Process Builder as well?

Leave a Reply

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