Getting Started with Process Builder – Part 8 (Auto Sync Accepted Quote with Opportunity)

Getting Started with Process Builder – Part 8 (Auto Sync Accepted Quote with Opportunity)

Last Updated on December 19, 2020 by Rakesh Gupta

To understand how to solve the same business use case using Salesforce Flow. Check out this article Getting Started with Salesforce Flow – Part 22 (Auto Sync Accepted Quote with Opportunity).

Big Idea or Enduring Question:

How do you automatically sync Accepted quotes with their respective Opportunity?

In this article working with related records, I had discussed a way to use Process Builder to update the Status of related Quotes to Denied for an Opportunity, whenever a Quote is accepted by the customer. Once a Quote is accepted by the customer, the next step is to Sync Accepted Quote with the Opportunity. In this article, I am going to discuss how to automate Quote Sync Process.

Objectives:

After reading this blog post, the reader will be able to:

  • Create an Auto-Launched flow to update records
  • Launch a Flow using Process Builder to automatically sync Quotes with the status of Accepted with the Opportunity.

Business Use Case

Steve Cartwright is working as a System administrator at Universal Containers (UC). He has received a requirement to Automatically Sync accepted Quote with Opportunity because business users always forget to Sync accepted Quote with Opportunity and it creates problems in reporting.

Automation Champion Approach (I-do):

There are multiple solutions possible for the above business scenario. You can either use an Apex trigger, a combination of Flow and Inline Visualforce Page, and a few more. We will use Flow and Process Builder to solve the above business requirement.

Before starting the Implementation, you have to understand one important concept related to the Sync Quote feature. There is a field on the Opportunity object i.e. Synced Quote. It’s nothing but a Lookup of the Quote Object. To automate Quote Sync Process, you have to populate the value in this field. This article will help you understand how to automate the Quote sync process and how to Launch a Flow from Process Builder. Follow the instructions to create a Flow and Process for the above business requirement.

Before discussing it, 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 2 steps to solve Steve’s business requirement using Flow and Process Builder. We must: 

  1. Lightning Flow Steps:
    1. Define flow properties for auto-launched flow
    2. And add text variable to store quote id
    3. Add text variable to store opportunity id
    4. Add an update records element  – update opportunity sync quote 
  2. Process Builder Steps:
    1. Define process properties
    2. Define evaluation criteria
    3. Define process criteria
    4. Add action – flows 

Step 1.1: Lightning Flow – Define Flow Properties 

  1. Click Setup.
  2. In the Quick Find box, type Flows.
  3. Select Flows then click on the New Flows.
  4. Select the Autolaunched Flow (No Trigger) option and click on Next and configure the flow as follows: 
    1. How do you want to start building: Freeform
  5. Click Done.

Step 1.2: Lightning Flow – Add Text Variable to Store Quote Id

  1. Under Toolbox, select Manager, then click New Resource to pass the Quote Id.
  2. Input the following information: 
    1. Resource Type: Variable
    2. API Name: varTQuoteId
    3. Data Type: Text
    4. Default Value: {!$GlobalConstant.EmptyString}
    5. Check Available for Input
    6. Check Available for Output
  3. Click Done.

Step 1.3: Lightning Flow – Add Text Variable to Store Opportunity Id

  1. Under Toolbox, select Manager, then click New Resource to store the Opportunity Id.
  2. Input the following information: 
    1. Resource Type: Variable
    2. API Name: varTOpportunityId
    3. Data Type: Text
    4. Default Value: {!$GlobalConstant.EmptyString}
    5. Check Available for Input
    6. Check Available for Output
  3. Click Done.

 

Step 1.4: Lightning Flow – Update Records (Update Opportunity – Sync Quote)

The next step is to update the Synced Quote field with Quote Id. For this, we will use the Update Records element. 

  1. Under Toolbox, select Element
  2. Drag-and-drop Update Records element onto the Flow designer. 
  3. Enter a name in the Label field; the API Name will auto-populate.
  4. Click Specify conditions to identify records, and set fields individually
  5. Object: Opportunity
  6. Select All Conditions Are Met (AND)
  7. Set Filter Conditions
    1. Row 1:
      1. Field: Id
      2. Operator: Equals
      3. Value: {!varTOpportunityId}
  8. Set Field Values for the Opportunity Records
    1. Row 1:
      1. Field: SyncedQuoteId
      2. Value: {!varTQuoteId}
  9. Click Done.

In the end, Steve’s Flow will look like the following screenshot:

Once everything looks good, perform the steps below: 

  1. Click Save.
  2. Enter Flow Label the API Name will auto-populate.
  3. Click Show Advanced.
  4. API Version for Running the Flow: 50
  5. Interview Label: Update Sync Quote {!$Flow.CurrentDateTime}
  6. Click Save

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

Our next task is to create a Process on the Quote object to Launch a Flow, only when a Quote is accepted by the customer. To create a Process on the Quote object, follow the instructions below:

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 Quote 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: Quote | Status
      2. Operator: Equals
      3. Type: Picklist
      4. Value: Accepted
  5. Select All of the conditions are met (AND)
  6. Click Advanced
  7. Select Yes to execute the actions only when specified changes are made to the record.
  8. 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 the criteria. This means that these actions won’t be executed when irrelevant changes are made.

Step 2.4: Add Action – Flows

  1. Below Immediate Actions, click Add Action.
  2. For Action Type, select Flows
  3. Name the action.
  4. Select the flow we just createdUpdate Sync Quote.
  5. Set Flow Variables: 
    1. Row 1:
      1. Flow Variable: varTOpportunityId
      2. Type: Field Reference
      3. Value: Quote | OpportunityId
    2. Click Add Row
    3. Row 2:
      1. Flow variable: varTQuoteId
      2. Type: Field Reference
      3. Value: Quote | Id
  6. Click Save.

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

Proof of Concept

Now onwards if a business user updates the Quote Status to Accepted, Process Builder will automatically Sync Accepted Quote with Opportunity.

  1. Below is the current status of Quote Sample Manufacturing 2020 in Presented Status before the update.
  2. Update the Quote Status to Accepted, as shown in the following screenshot.
  3. Once you are done, click on the Save button.
  4. Now check the Syncing Check-box available on the Quote object. It’s already checked because the Process Builder Auto Sync Accepted Quote with Opportunity, as shown in the following screenshot:

Opportunity

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!

24 thoughts on “Getting Started with Process Builder – Part 8 (Auto Sync Accepted Quote with Opportunity)

  1. Thank You Rakesh for the great work. One quick question! How would I solve the above business requirement with Process Builder only if I don’t want use flow?

  2. Is it possible to use process builder and flow to sync custom fields from the qli and quote to the opp products and opportunity and vice versa? There is a package on the app exchange that does this however it is not lightning compatible.

  3. Thank Rakesh. A quick query. Why can’t i use “Select a record related to the Quote” option in place of flow to update SyncQuoteId?

  4. Hello Rakesh, great work really helpful. I am having a small issue and was hoping you could guide me to the right direction. So i implemented what you shared with a minor change to the process builder to trigger when the custom checkbox is checked. This checkbox is autochecked by the approval process once the quote gets approved but for some reason the Process builder or the flow do not execute to autosync. If i check the checkbox manually ti works fine. Any recommendations?
    Thank you.

    1. Got you. Please follow the instructions below

      1. Open you Approval process
      2. Locate the field update, that updates checkbox to true
      3. Make sure to select “Re-evaluate Workflow Rules after Field Change” checkbox

    1. Add one criteria node in your process to check the quote status != Accepted and prior Status is not Accepted then set sync = False

  5. HI again Rakesh,

    I set up this process in my Sandbox, and am getting a recursive trigger error:

    Error Occurred: UPDATE — UPDATE FAILED — ERRORS : (CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY) quotesync.OppLineSyncTrigger: execution of AfterUpdate,

    Any suggestions on what the issue is?

    1. Hi Bailey,

      I’m having the same problem (quote gets created without products) and I was wondering if you were able to to solve this?

      Thanks in advance & best Regards,
      Ben

  6. Hi Rakesh,

    This is exactly what I was looking for thank you!
    Currently, I have a process builder that creates a new related quote whenever a new opportunity is created that is a certain record type (and has a least 1 product line item on the opportunity.)
    It works, except the quote gets created without products.
    Would I be able to use this use case to sync the quote and opportunity products for the newly created quote?

    1. If there are no quote line items in the quote, then after sync all opportunity products will be deleted.

      I will suggest you to create another process on Opportunity product to copy line items to quote

      1. With a process builder or will I need to also create a flow?
        I created a process builder but am having trouble finding the correct related object to update in the action.

  7. Hi Rakesh,

    Thanks for the great examples.

    I implemented and tested it… works great. But when I change the status of quote from ‘Acccepted’ to let’s say ‘In Review’ the sync should stop. How would I extend the above example to implement this.

    Please help

Leave a Reply

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