Getting Started with Process Builder – Part 31 (Dynamic Approval Routing in Salesforce)

InSalesforceuser can useApproval process to get approval from managers or higher authority.Approval processes route a record to one or more approvers, specifying the steps necessary for a record to be approved, and who must approve it at each step. In a normal approval process, i.e.Static approval process, the approvers at each step are explicitly specified in each step approval process, or you can have the submitter choose the approver manually, as shown in the following screenshot

Static approval process

Whereas dynamic approval routing allows us to specify the approvers for each record usingUserlookup fields on the record requiring approval. These fields can be populated using the Process Builder orApex, using data from a special custom object/setting that contains all the information needed to route the record. Dynamic approval routing provides the flexibility to route the approval request to different people based on Account Type or some other criteria related to the record.Let’s start with a business use case

Business Use case

Steven Greene is working as System administrator in Universal Container. He has received a requirement from the management, to route opportunity approval requests to designated approvers, based on the opportunity’s Lead Source and the opportunity’s account type.

Solution for the above business requirement

There are a few possible solutions for the above business scenario, but I’ll use Process Builder and Flowto solve the above business requirement. Steps to create dynamic approval routing are mentioned below

Create a custom lookup (with user object) field on the object being approved

Create a custom settings/object that will be used as an approval matrix

Populate the approval matrix, i.e. create a few records in Custom settings/object

Use Flow and Process Builder to populate the lookup field on the record, from the approval matrix

Create or update an approval process to utilize the new lookup fields

Follow the below instructions to solve the above business requirement

1.Create a custom lookup field on the Opportunityobject, called as Opportunity Approver as shown in the following screenshot

Custom field

2. The next step is to create a custom object (Approver Matrix) and few custom fields to store all the fields used in routing, as shown in the following screenshot

Custom Object

3. The next step is to create the approval matrix records. For exampleLead Source = WebandType =Existing Customer – Upgrade, one might route the records to Helina Jolly asOpportunity Approver. It will loo like the following screenshot

Approver Matrix

4. Now we will use Flowand Process Builderto populate the lookup field Opportunity Approver on the opportunity record, from the approval matrix.

Click on Name | Setup | App Setup | Create | Workflows & Approvals | Flows and then click on the New Flow, it will open the Flow canvas for you. Now create few Text variables VarT_LeadSource, VarT_Type, VarT_OpportuntiyApprover and VarT_OppIdto store Lead source, Opportunity Type, opportunity Approver and Opportunity Id respectively.

5. The next step is to get the Opportunity approver, for this we will use record lookup element. To do this drag-and-drop Record Lookup element (Enter the name To get opportunity approver) onto the canvas and map the fields according to below details

Save the Opportunity approver in a Text variable as shown in the following screenshot

Record Lookup – To get Opportunity Approver

6. Now we will use theDecision element to check the Text Variable{!VarT_OpportuntiyApprover}size. If the Text Variable is not equal tonullthen we will go ahead and update Approver on opportunity record otherwise, we will update it with a default approver. You can take help from the following screenshot to create a DecisionElement

Decision Element – Check Text Variable Size

7. The next step is to update an Opportunity record. For this, we will useRecord Update element. Drag-and-drop Record Update element (Enter the name Update Opportunity Approver) onto the canvas and map the fields according to the following screenshot

Record Update – To update opportunity approver

8. In case if there are no approver exist inApprover Matrixfor the current opportunity based on Type and Lead Source then we will update,Opportunity Approverwith a default user Id. For this, we will useRecord Update element. Drag-and-drop Record Update element (Enter the name Update Default approver ) onto the canvas and map the fields according to the following screenshot

Launch a Flow from Process Builder

Our next task is to create a Process Builder on theOpportunity object to launch a Flow. To create a Process Builder on theOpportunity object follow the below instructions

1. Click on Name | Setup | App Setup | Create | Workflows & Approvals | Process Builder and click on the New button, Enter Name, API Name and then click on the Save button

Define Process Properties

2. The next step is to add entry criteria. For this click onAdd Object, selectOpportunity object and for the entry criteria, Select when a record is created or edited, as shown in the below screenshot, once you are done click on theSave button

Evaluation Criteria

3. The next task is to add ProcessCriteria, To do this click on Add Criteria, enter Name, Type of action and set filter conditions(In this case set [Opportunity].LeadSource Is Null False or [Opportunity].Type Is Null False ) and click on the Save button as shown in the following screenshot

Process Criteria

4. The next step is to addan Immediate action to Process. Click onAdd Action(Under Immediate actions), Select the type of action to create (In our case Flows), and then fill out the fields to define the action, as shown in the following screenshot

Add action – Flows

5. Once you are done, click on theSave button, it will redirect you to Process canvas. Finally, theProcess will look like the following screenshot

Don’t forget to active the Process by clicking on the Activatebutton.

Modify the existing approval process

The final step is to modify the existing approval process. I assume that you have created an active approval process on Opportunityobject, as shown in the following screenshot

Approval process on Opportunity

Now modify the approver step, and select related userOpportunity approver, as shown in the following screenshot

Select Assigned Approver

It’s time to test this feature

1) Navigate to theOpportunity tab, identify theOpportunity and click on Opportunity Name. 2) Update the Lead Source and Type, Process Builder automatically populate the Opportunity approver field, as shown in the following screenshot

Opportunity Record

3) Finally, submit an Opportunity record for approval.

Approval Request

Note: – I will suggest you to implement this first on your developer org, test it and then move it to production. Don’t try to implement this in Spring’15 org, otherwise, you will get an error.

3 thoughts on “Getting Started with Process Builder – Part 31 (Dynamic Approval Routing in Salesforce)”

Rebecca Ralls

Expanding on this: Is there a way to dynamically assign multiple approvers for a record? I have a header Record with 1 to many child records, and each child record can be assigned to a different department. I want my header record to be approved by the manager of every department who has any child records assigned to them. The department is a lookup field, and the manager is specified on the department record. I am proficient with both process builder and flow, but I haven’t quite figured out how to solve this.