top of page

Article 001

Dynamic Approval Process With Process Builder

In Salesforce user can use Approval 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 using User lookup fields on the record requiring approval. These fields can be populated using the Process Builder or Apex, 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 of above business requirement

There are a few possible solutions for the above business scenario, but I’ll use Process Builder and Flow to 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 Opportunity object, 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 example Lead                                                       Source =Web and Type = Existing Customer – Upgrade, one might route the records to Helina Jolly           as Opportunity Approver. It will loo like the following screenshot

 

 

 

 

 

 

 

                                                                      APPROVER MATRIX

 

4. Now we will use Flow and Process Builder to populate the lookup fieldOpportunity 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 andVarT_OppId to store Lead source, Opportuntiy Type, opportunity Approver and Oportunity 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

  • Select Object Approver_Matrix__c

  • For criteria select Type__C= {!VarT_Type} andLead_Source__C= {!VarT_LeadSource}.

  • 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 the Decision element to check the Text Variable{!VarT_OpportuntiyApprover} size. If         the Text Variable is not equal to null then 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 Decision Element

 

 

 

 

 

 

 

 

 

 

                                           DECISION ELEMENT – CHECK TEXT VARIABLE SIZE

 

7. The next step is to update an Opportunity record. For this we will use Record Update element. Drag-           and-drop Record Update element (Enter the name Update Opportuntiy 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 in Approver Matrix for current opportunity based on Type and Lead     Source then we will update, Opportunity Approver with a default user Id. For this we will use Record           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

 

 

 

 

 

 

 

 

 

 

 

 

 

                                         RECORD UPDATE – TO UPDATE DEFAULT APPROVER

 

Finally your Flow will look like the following screenshot

 

8. Save your flow with name Dynamic Approval Routing and close the canvas. Don’t forget to Activate the Flow.

Launch a Flow from Process Builder

Our next task is to create a Process Builder on the Opportunity object to launch a Flow. To create a Process Builder on the Opportunity 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 theSave button

 

 

 

 

 

 

 

 

 

                                                             DEFINE PROCESS PROPERTIES

 

2. The next step is to add entry criteria. For this click on Add 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 the Save button

 

 

 

 

 

 

 

 

 

 

                                                                   EVALUATION CRITERIA

 

3. The next task is to add Process Criteria, To do this click on Add Criteria, enterName, 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 add an Immediate action to Process. Click on Add 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 the Save button, it will redirect you to Process canvas. Finally the Process will look like the following screenshot

 

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

Modify the existing approval process

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

 

 

 

 

 

 

 

 

 

 

 

 

 

                                                    APPROVAL PROCESS ON OPPORTUNITY

 

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

 

 

 

 

 

 

 

 

 

 

 

                                                             SELECT ASSIGNED APPROVER

 

It’s time to test this feature

1) Navigate to the Opportunity tab, identify the Opportunity 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.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Static Approval Process
bottom of page