Getting Started with Process Builder – Part 98 (What say? Send an Opportunity Approval Request to a Queue? Really?)

Getting Started with Process Builder – Part 98 (What say? Send an Opportunity Approval Request to a Queue? Really?)

Last Updated on August 10, 2020 by Rakesh Gupta

An approval process is an automated process an organization can use to approve records in Salesforce. One can create, either a one-step or a multi-step, approval process in Salesforce based on your business needs. 

Let us take a simple use case – submit an Opportunity Approval to a Queue

Wait a minute, you yell! I know Salesforce enough to know that an Opportunity approval request cannot be sent to Queue! In sheer disbelief, you continue to remind me that one can only send an approval request to Queues (in case of a custom object, Lead, and Case) or Users

You are right, I am glad to admit! True, out-of-the-box, Opportunity doesn’t support a Queue – let alone creating an approval process and assigning it to a queue. Therefore, creating an approval on an Opportunity object using Queues needs out-of- the-box thinking!!

Objectives:

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

  • Understand what a Queue is.
  • Use filters and conditions to design a process.
  • Understand the Submit for approval action in Lightning Flow.
  • Last but not the least, see how to submit opportunity approval to a queue! 

Business Use case

Martin Jones is an App Developer at Gurukul on Cloud (GoC). He received a requirement –  when an opportunity is created, or updated, with an amount greater than $5M, assign it to a queue named ‘Top Management’ for approval

What is a Queue?

Queues permit groups of users to prioritize, distribute, and assign records to teams that share workloads. A queue is a location where records can be routed to await processing by a group member. 

A queue is available for objects like cases, contact requests, leads, orders, custom objects, service contracts, and knowledge article versions etc. 

Automation Champion Approach (I-do):

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

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

As of Summer’20 release, Lightning Flow doesn’t support formulas like ISCHANGED and PRIORVAULE. This means, it is not possible to just fire a Flow on changes to an opportunity’s amount. 

Let us solve this scenario using Process Builder and Lightning Flow. 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.

Process Builder 98 - process flow

Let’s begin building this automation process.

Guided Practice (We-do):

There are 3 steps to solve Martin’s business requirement using Process Builder and Flow. First an overview: 

  1. Create an Approval Process
  2. Create a Queue
  3. Lightning Flow Steps:
    1. Add a Get Records Element
    2. Use Assign Element to store value in a Collection
    3. Add Action – Submit for Approval  
  4. Process Builder Steps
    1. Define Process properties
    2. Define Evaluation Criteria
    3. Define Process Criteria
    4. Add Action – Flow

Step 1: Creating an Approval Process

  1. Click Setup.
  2. In the User Interface, type Approval Processes.
  3. Clicks on the Approval Processes.
  4. Create a New approval process on Opportunity as shown in the following screenshot.
  5. Click Save.

Process Builder 98.2 -Create an Approval process

Make sure that the Assigned Approver in the very first step of the approval process is Manually Chosen

Step 2: Creating a Queue

  1. Click Setup.
  2. In the User Interface, type Queues.
  3. Clicks on the Queues and then click on the New button.
  4. Enter a name in the Label field; the Queue Name will auto-populate. 
  5. Now select any random object for Supported Objects as it is required. In this case select Lead, Case or Custom Object (as we can’t leave this field blank).  
  6. Add the users to the queue. 
  7. Click Save.

Process Builder 98.3 - Create a Queue

Step 3.1: Lightning Flow – Adding a Get Record Element

  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 option and click on Create.
  5. Drag-and-drop Get Records element onto the Flow designer. 
  6. Enter a name in the Label field; the API Name will auto-populate.
  7. Select the Group object from the dropdown list.
  8. Set Filter Conditions
    1. Row 1:
      1. Field: DeveloperName
      2. Operator: Equals
      3. Value: Top_Management
    2. Row 2:
      1. Field: type
      2. Operator: Equals
      3. Value: Queue
  9. For How Many Records to Store select Only the first record.
  10. For How to Store Record Data select the option to Automatically store all fields
  11. Click Done.

Process Builder 98.3 -Add a Get Records

Step 3.2: Lightning Flow – Using Assignment Element to store Queue Id in a Collection 

  1. Create a Text variable varTQueueIds which allows you to store multiple values in the Ids of Queues or Users. Process Builder 98.4 - COllection Variable
  2. Drag-and-drop Assignment element onto the Flow designer. 
  3. Enter a name in the Label field; the API Name will auto-populate.
  4. Set Variable Values
    1. Row 1:
      1. Field: {!varTQueueIds}
      2. Operator: Add
      3. Value: {!Find_Queue_ID.Id}
  5. Click Done.

Process Builder 98.4 - Assignment Element

Step 3.3: Lightning Flow – Add Action – Submit for Approval

  1. Create a Text variable varTOpportunityId to store the Opportunity ID (We will pass the Opportunity record ID through the process builder). Process Builder 98.5 - Create a Text Variable
  2. Drag-and-drop Action element onto the Flow designer. 
    1. Select Submit for Approval standard action. 
  3. Enter a name in the Label field; the API Name will auto-populate.
  4. Set Input Values
    1. Row 1:
      1. RecordId: {!varTOpportunityId}
      2. Approval Process Name Or ID: X10M_Deal_Approval_Process (API Name of approval process) 
      3. Next Approver IDs: {!varTQueueIds}
  5. Click Done.

Process Builder 98.9 - Submit for Approval

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

Process Builder 98.6 - Flow

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

Step 4.1: Process Builder – 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.

Process Builder 98.7 - Define Process Properties

Step 4.2: Process Builder – 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.

Evaluation Criteria

Step 4.3: Process Builder – 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 | Amount
      2. Operator: Greater than
      3. Type: Currency
      4. Value: 5000000
  5. Select All of the conditions are met (AND)
  6. Click Save.

Process Builder 98.8 - Define Process Criteria

Step 4.4: Process Builder – Add Action – Flows

  1. Below Immediate Actions, click Add Action.
  2. For Action Type, select Flows
  3. Name the action.
  4. Select the Submit record to Queue Flow. 
  5. Set Field Values:
    1. Field: varTOpportunityId
    2. Type: Field Reference
    3. Value: [Opportunity].Id
  6. Click Save.

Process Builder 98.9 - Add Action - Flow

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 the validation rules then, make sure you add those fields. Conversely, if some fields are required on the page layout, you can ignore those fields. 

It’s time to test this feature!

Next time, when a Sales rep creates, or updates, an opportunity with an amount greater than $5M – It will submit to Queue approval.

Great! You are done! Feel free to modify it based on your business requirement. 

Things to Remember

  1. Make sure that the user must have access to the Opportunity record he needs to approve. 
  2. If you have a multi-step opportunity approval process, and you want to send step three to Queue’s approval, consider breaking into two approval process as shown in the following screenshot:

Break Approval Process

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.

Note: –  I am grateful to Copado, Docomotion, FormAssembly, and OwnBackup for sponsoring my blog.

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

Leave a Reply

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