Getting Started with Process Builder – Part 22 (Discover How to Auto Populate Delegated Approver Field on a New User Record!)

Getting Started with Process Builder – Part 22 (Discover How to Auto Populate Delegated Approver Field on a New User Record!)

Last Updated on December 9, 2020 by Rakesh Gupta

Big Idea or Enduring Question:

How do you Auto-Populate Delegated Approver Field on a New User Record?

Objectives:

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

  •  Create a Process Builder and Flow to auto-populate the delegated approver field for new users.

Business Use case

Warren Mason is working as a System administrator at Universal Containers (UC) received the following requirement – On a New User’s record, auto-populate the User’s Manager as a delegated approver.

Automation Champion Approach (I-do):

The delegated approver is an alternate approver. If populated, this user receives the same approval requests as the original approver. Delegated approvers don’t have the ability to reassign approval requests – they can only approve or reject approval requests. 

Assigning a delegated approver comes in handy when a User is out of office. In such circumstances, a delegated approver, designated by the User, can approve requests on behalf of the User. However, if the Users forget to configure delegated approvers/administrators then, this would delay approval of requests, if and when, they are out of office. A User can select a delegated administrator/approver by navigating to his/her personal settings.

In this article, we will discuss how to automate the process of auto-populating a new User’s Manager as a delegated approver. There are multiple solutions possible for the above business scenario.

You can either use an Apex trigger, Flow, and a few more. We will use Flow and Process Builder to solve the above business requirement. 

Before proceeding ahead, you have to understand the User object. It Represents a Chatter user profile.

Field Name Details
DelegatedApproverId Id of the user who is a delegated approver for this user.

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 Warren’s business requirement using Flow and Process Builder. We must:

  1. Lightning Flow Steps:
    1. Define flow properties for auto-launched flow
    2. Add a record variable to store user record details 
    3. Add an update records element  – update DelegatedApproverId 
  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 Flow.
  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 a Record Variable to Store User Record Data

  1. Under Toolbox, select Manager, then click New Resource to store User Id.
  2. Input the following information: 
    1. Resource Type: Variable
    2. API Name: varRUser
    3. Data Type: Record
    4. Object User
    5. Check Available for Input
    6. Check Available for Output
  3. Click Done.

Step 1.3: Lightning Flow – Update Records (Update Delegated Approver same as Manager)

The next step is to update the User’s Manager as a delegated approver. For this, we will update the DelegatedManagerId field on the user record. For this, we will use an Update Record 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: User
  6. Select All Conditions Are Met (AND)
  7. Set Filter Conditions
    1. Row 1:
      1. Field: Id
      2. Operator: Equals
      3. Value: {!varRUser.Id}
  8. Set Field Values for the Case Records
    1. Row 1:
      1. Field: DelegatedManagerId
      2. Value: {!varRUser.ManagerId}
  9. Click Done.

In the end, Warren’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: Assign Delegated Approver Automation {!$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 User object to Launch a Flow, only when a user is created. To create a Process on the User 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 User object from the dropdown list.
  3. Start the process only when a record is created.
  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: User | ManagerId
      2. Operator: Is null
      3. Type: Boolean
      4. Value: False
  5. Select All of the conditions are met (AND)
  6. Click Save.

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 createdAssign Delegated Approver Automation.
  5. Set Flow Variables: 
    1. Row 1:
      1. Flow Variable: varRUser
      2. Type: Field Reference
      3. Value: Select the User record that started your process
  6. Click Save.

In the end, Warren’s Process will look like the following screenshot:

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

Proof of Concept

Now onwards if a user is created, the Delegated Approver will be automatically populated. 

  1. Navigate to Setup | Administration | Users | Users
  2. Create a New User and mark as Active, make sure to populate Manager.
  3. Click Save.
  4. Now navigate to the Delegated Approver field in the user detail page and check whose name is populated – yes you are right it’s James Smith!!!

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!

2 thoughts on “Getting Started with Process Builder – Part 22 (Discover How to Auto Populate Delegated Approver Field on a New User Record!)

Leave a Reply

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