© Rakesh Gupta 2020
R. GuptaSalesforce Platform App Builder Certificationhttps://doi.org/10.1007/978-1-4842-5479-0_6

6. Automating Business Processes

Rakesh Gupta1 
(1)
Katihar, India
 

In Chapter 5, we covered record types, followed by an in-depth overview of data improvement tools such as lookup filters, formula fields, and rollup summary fields. Last, we looked at validation rules with real-life examples.

This chapter is comprised of three parts. Part one is divided into three sections, part two is divided into two sections, and part three consists of one section.

In part one, the first section includes of an overview of the Lightning Flow life cycle. The second section takes a close look at Lightning Flow Designer. A few use cases are discussed in the third section.

In part two, the first section consists of an overview of Lightning Process Builder, including when to use which automation tool. In the second section, we work through a few use cases of Lightning Process Builder.

In part three, we focus exclusively on the approval process, with a real-life example.

Introduction to Lightning Flow

Lightning Flow is a drag-and-drop interface that allows you to automate business processes by using clicks, not code. Using Lightning Flow, you can undertake a few actions; create, update, and delete records; send e-mail; submit records for approval; send notifications to Salesforce mobile; automate Quip; post a message to chatter; and, last but not least, create a guided process and make it available to end users.

Lightning Flow can run automatically without using any manual intervention. It has the ability to interact with Salesforce objects (many of them are not available through workflow rules or Lightning Process Builder) and to invoke Apex classes (an Apex class implements the Process.Plugin interface or @InvocableMethod annotation). Using Lightning Flow, you can create a series of screens to take user input to collect the data and process them in Salesforce, based on your logic.

Let’s meet up with Pamela Kline again, who has just received a new request from her manager: add new users automatically to a public group named Company Announcements.

Pamela has several options for meeting this requirement:
  1. 1.

    Apex trigger: This option requires Apex programming skills. That said, Pamela must write a test class to deploy the Apex trigger into production, which is a time-consuming undertaking, to say the least.

    trigger addintoPublicgroup on User (after insert) {
      for (User AddUser: trigger.new)
       {
                   If (AddUser.Isactive == True)
             {
           // Your logic;
    }
         }
       }
     
  2. 2.
    Lightning Flow and Lightning Process Builder: This option combines tools, as shown in Figure 6-1.
    1. a.

      In Lightning Flow, Pamela would write the logic to add people to the public group.

       
    2. b.

      Using Lightning Process Builder, Pamela can fire Lightning Flow whenever a user record gets created.

       
     
../images/472313_1_En_6_Chapter/472313_1_En_6_Fig1_HTML.jpg
Figure 6-1

A Lightning Flow and Lightning Process Builder solution

Note

A flow can be fired automatically using Process Builder or, if it is scheduled to run at a specified time, it can run at a scheduled time.

Advantages of Using Lightning Flow

The benefits of using Lightning Flow over Apex include the following:
  • The flow allows you to automate a business process using clicks, not code.

  • It does not require coding skills. Without knowing Apex code, you can develop a flow to automate business processes.

  • It allows you to manipulate data for certain objects that are not available through workflow rules or Process Builder—for example, Group, GroupMember, PermissionSetAssignment, and more.

  • It can be maintained easily by nondevelopers.

  • Because it is not code, you don’t need to write test classes (although there are a few exceptions to this).

One of the few downsides of using Flow, however, is that you can make changes directly in an organization’s production org, just like any other configuration. Ouch!

Lightning Flow Life Cycle

Lightning Flow Designer is a tool for creating, configuring, and managing flows. It is used to define business logic for your flows without you having to write a single line of code. Designer has three different parts:
  1. 1.

    Design: Lightning Flow Designer is a tool to create flows, configure screens, and define business logic for your flows without writing a single line of code.

     
  2. 2.

    Administration: After you create a flow, you can manage it, edit its properties, grant flow access to profiles, activate it, deactivate it, delete it, save it as a new version or a new flow, or just run an existing flow.

     
  3. 3.

    Runtime: You can run an active flow from a custom button, link, Flow action, Lightning page, and more. If it is an autolaunched flow, then it can be executed through Process Builder or run at a specified time.

     

An Overview of Lightning Flow Designer

As mentioned, Lightning Flow Designer is a tool to create flows, configure screens, and define business logic for your flows without requiring a single line of code. Flow Designer’s user interface has several different functional parts (Figure 6-2):
../images/472313_1_En_6_Chapter/472313_1_En_6_Fig2_HTML.jpg
Figure 6-2

Lightning Flow Designer

  1. 1.
    The button bar: You can use the Save, Save As, Activate, Debug, Run, Undo, and Redo buttons to perform specific activities:
    1. a.

      Save: Use this option to save your flow.

       
    2. b.

      Save As: Use this option to clone a flow or create a new version of the flow

       
    3. c.

      Activate: Use this option to activate the flow.

       
    4. d.

      Debug: Use this option to see the real-time details of what your flow does and why it is not working. Set input variables and restart the flow at any time to debug a different branch.

       
    5. e.

      Run: Use this option to run the most recent version of the flow you are working on.

       
    6. f.

      Flow Properties: Click the screwdriver icon to see information related to your flow, such as name, unique name, description, flow type, interview label, version, and created and modified dates.

       
    7. g.

      Copy or Paste: Use this option to copy and paste a flow element (such as Screen, Create Records, and Decision) one at a time.

       
    8. h.

      Undo or Redo: Use this option to undo or redo recent activities in Flow Designer.

       
     
  2. 2.

    The Flow Designer: You can use this area to design your flow. You can edit any element by double-clicking it.

     
  3. 3.

    Elements: This is the area where you find all the element types available for your flow. You drag and drop elements from the palette onto the Flow Designer to use them.

     
  4. 4.

    Manager: The Manager tab contains all the elements and resources added to the flow.

     

Different Ways to Launch a Flow

After you are done with flow development, the next task is to distribute the flow so business users can use it. There are several ways business users can run the flow:
  1. 1.

    Flow Action

     
  2. 2.

    Lightning app page

     
  3. 3.

    Lightning home page

     
  4. 4.

    Custom button or link

     
  5. 5.

    Login flow

     
  6. 6.

    Process Builder

     
  7. 7.

    Automatically at a specified time

     
  8. 8.

    Lightning component

     
  9. 9.

    The Apex start () method

     
  10. 10.

    Visualforce page

     

This list is not exhaustive. Now that we’ve looked at the nuts and bolts of Lightning Flow, let’s see how we can use it in real life.

Use Case 1: Mortgage Broker Commission Calculator

At GoC, mortgage brokers often get confused about their commission for a given deal. They are having a hard time calculating the commission correctly. Pamela Kline wants to create an application that allows mortgage brokers to calculate their commission.

On the very first screen, she wants to allow mortgage brokers to enter the property the value (in dollars) and the commission (as a percentage), as shown in Figure 6-3.
../images/472313_1_En_6_Chapter/472313_1_En_6_Fig3_HTML.jpg
Figure 6-3

Mortgage broker commission calculator

On the next screen, Pamela wants to display the commission amount (in dollars), as shown in Figure 6-4.
../images/472313_1_En_6_Chapter/472313_1_En_6_Fig4_HTML.jpg
Figure 6-4

Calculator displays the commission amount

Pamela does this by performing the following steps:
  1. 1.

    She navigates to Setup (gear icon) ➤ SetupPLATFORM TOOLSProcess AutomationFlow.

     
  2. 2.

    She then clicks the New Flow button, which opens a pop-up, where she selects the Screen Flow option and then clicks the Create button. These actions open Lightning Flow Designer.

     
  3. 3.

    Pamela navigates to the Elements tab and drags and drops the Screen element to Lightning Flow Designer, which opens a Screen element window.

     
  4. 4.
    She enters the label Mortgage broker commission calculator and adds a description. Then she uses the Configure Frame section to control the appearance of the header and footer. Within the Control Navigation section, she selects the Next or Finish option only, as shown in Figure 6-5.
    ../images/472313_1_En_6_Chapter/472313_1_En_6_Fig5_HTML.jpg
    Figure 6-5

    Configure Screen element properties

     
  5. 5.
    Next, Pamela uses the Screen element to display the fields so that mortgage brokers can enter the property value and their commission as a percentage. She drags and drops the Currency field onto the Screen element and configures it by clicking the Currency field to configure its settings by entering the following information:
    1. a.

      Label: She enters the label for the input currency field. In this case, Pamela enters Property value ($) as the label.

       
    2. b.

      API Name: This field autopopulates based on the label.

       
    3. c.

      Require: She selects this check box to make the field required.

       
    4. d.

      Default Value: Users can enter a default value for this field that would prepopulate the value for the component. For this requirement, Pamela leaves the field empty.

       
    5. e.

      Decimal Places: Pamela uses this field to control the number of digits to the right of the decimal point. She knows the number of digits can’t exceed 17.

       
    6. f.

      Set Component Visibility: Pamela uses this section to control component visibility based on the flow’s attributes.

       
    7. g.

      Validate Input: Here, Pamela knows she can provide a formula that evaluates whether the value that is entered is valid. She also knows she should add an error message to display if the value input is invalid.

       
    8. h.

      Provide Help: Pamela knows she can use this field to give her users more context with this screen component.

       
    At the end, Pamela’s screen component looks like Figure 6-6.
    ../images/472313_1_En_6_Chapter/472313_1_En_6_Fig6_HTML.jpg
    Figure 6-6

    Configure currency component properties

     
  6. 6.
    Then, Pamela adds the Number field to allow mortgage brokers to enter their commission as a percentage. At the end, her flow looks like Figure 6-7.
    ../images/472313_1_En_6_Chapter/472313_1_En_6_Fig7_HTML.jpg
    Figure 6-7

    Configuring number component properties

     
  7. 7.

    When she is finished, she clicks the Done button.

     
  8. 8.
    To calculate the commission amount, Pamela creates a formula. To do this, she navigates to the Manager tab and clicks the New Resource button. This opens a pop-up window where she configures the formula, as shown in Figure 6-8.
    ../images/472313_1_En_6_Chapter/472313_1_En_6_Fig8_HTML.jpg
    Figure 6-8

    Formula to calculate commission amount

     
{!Property_value} and {!Commission} are screen input fields Pamela created in steps 5 and 6.
  1. 9.

    When she is finished, she clicks the Done button.

     
  2. 10.

    The next task is for her to display the commission amount on the screen. For that, Pamela drags and drops the Screen element from Elements to Flow Designer. This opens a Screen element window, where Pamela enters the name Display mortgage commission amount. She uses the Configure Frame section to control the appearance of the header and footer. Within the Control Navigation section, Pamela selects the Next or Finish option only.

     
  3. 11.

    Now she navigates to the Screen Component section and double-clicks Display Text, which is available in the Display section.

     
  4. 12.
    In the screen overlay preview pane, Pamela clicks the Display Text field to configure its settings by entering the API name. From the Display Text drop-down, Pamela selects the formula she created in step 8. The final product looks like Figure 6-9.
    ../images/472313_1_En_6_Chapter/472313_1_En_6_Fig9_HTML.jpg
    Figure 6-9

    Configure second screen to display commission amount

     
  5. 13.

    When she is finished, Pamela clicks the Done button.

     

Connecting the Flow Elements

So far, Pamela has created two screens: one for getting the inputs from the mortgage broker and the other to display the commission amount in dollars. Now Pamela needs to connect both elements so that, at runtime, the flow can decide the order of execution of the elements.
  1. 1.
    To do this, in the Start element, Pamela finds the node at the bottom and drags the node to the target element, as shown in Figure 6-10.
    ../images/472313_1_En_6_Chapter/472313_1_En_6_Fig10_HTML.jpg
    Figure 6-10

    Connecting the flow elements

     
  2. 2.

    Next. Pamela she clicks the Save button and enters Mortgage broker commission calculator as the name to save the flow.

     
  3. 3.

    Pamela does not forget to activate the flow! She does so by clicking the Activate button.

     

Activating a Version of a Flow

When users activate a flow, Salesforce does not allow them to modify the activated flow. At this point, users have two options:
  1. 1.

    Create a new flow by cloning the activated flow.

     
  2. 2.

    Modify the activated flow, save it as a new version, and then modify it. When users are done with modification, they can activate the new version of the flow.

     

Users can have multiple versions of a flow, but they can activate only one version of a flow at a time. From the flow detail page, Salesforce allows users to activate or deactivate one version of a flow. Users click the Activate link next to the version of the flow they want.

Displaying a Flow from the Lightning Home Page

At this point, Pamela has created and activated a flow. The next step is to distribute it, so that mortgage brokers can use it. She wants to place this application on the Lightning home page. She does this by performing the following steps:
  1. 1.

    She edits the Lightning home page by navigating to App Builder.

     
  2. 2.

    She drags and drops the flow component onto the page.

     
  3. 3.

    Next, she selects the flow she wants to display—in this case, Mortgage Broker Commission Calculator.

     
  4. 4.

    She can also select the layout (one or two columns) and she can set component visibility, which Pamela leaves as the default value.

     
  5. 5.

    When she is done, she clicks the Save button. At then end, her flow looks like Figure 6-11.

     
I hope you now have a better understanding of how to create a flow and activate it for business users.
../images/472313_1_En_6_Chapter/472313_1_En_6_Fig11_HTML.jpg
Figure 6-11

Displaying a flow in the Lightning home page

Use Case 2: Delete Unqualified Leads

Pamela Kline has received the following requirement from her manager: whenever a lead is updated as unqualified, delete it. This will help GoC maintain a clean database.

First, we have to understand why we need to use Lightning Flow here. Can’t this be done through Process Builder? The answer is no! This is because, as of the proposed Winter 2020 release, a process built in Process Builder won’t have the ability to delete a record.

A flow can be invoked manually using buttons, links, or actions. In Pamela’s situation, she needs to call the flow automatically whenever a lead is updated to unqualified, and then delete the record. In such cases, we need to invoke the flow from Process Builder. Figure 6-12 shows the process flow diagram for the new business requirement.
../images/472313_1_En_6_Chapter/472313_1_En_6_Fig12_HTML.jpg
Figure 6-12

Process flow diagram for use case 2

Now that you understand why we need to use two tools to solve this requirement, let’s plow through the following steps:
  1. 1.

    Lightning Process Builder: When a lead is updated as unqualified, Process Builder calls a flow and passes LeadId to it.

     
  2. 2.

    Lightning Flow: A flow is used to delete the Lead record based on the ID passed by Process Builder using the Delete Records element.

     

In this section, we look at Lightning Flow only. We look at the Process Builder part in the next section.

Pamela performs the following steps to solve the preceding business requirement using Lightning Flow:

  1. 1.

    She makes sure to add Unqualified as a value in the Lead Status field.

     
  2. 2.

    Then she navigates to Setup (gear icon) ➤ SetupPLATFORM TOOLSProcess AutomationFlow.

     
  3. 3.

    She clicks the New Flow button, which opens a pop-up, where she selects the Autolaunched Flow option, and then clicks the Create button, which opens Lightning Flow.

     
  4. 4.
    Pamela navigates to the Manager tab and creates the text variable VarTLeadID. She sets its availability outside the flow as available for input and output. For Default Value she uses {!$GlobalConstant.EmptyString}. Her flow looks like Figure 6-13. Later, she passes the value to this variable through Process Builder.
    ../images/472313_1_En_6_Chapter/472313_1_En_6_Fig13_HTML.jpg
    Figure 6-13

    Creating a text variable

     
  5. 5.
    Pamela navigates to the Elements tab and drags and drops the Delete Records element onto Lightning Flow Designer. This opens a new window, where she enters the following details:
    1. a.

      Label: She enters the label for the input currency field. In this case, she enters Delete lead records as the label.

       
    2. b.

      API Name: This field autopopulates based on the label.

       
    3. c.

      Description: Pamela writes some meaningful text so other developers and administrators can understand easily why this Delete Records element was created. When users select the Delete Records element in the Explorer tab, the description appears in the Description area.

       
    4. d.

      How to Find Records to Delete: Pamela selects the Specify conditions option.

       
    5. e.

      Delete Records of This Object Type: She selects the object for which she wants to delete the record. In this case, she selects the Lead object.

       
     
  1. 6.

    Next, Pamela needs to set the filter criteria to identify which record gets deleted. In this scenario, she selects the Id = {!VarTLeadID} text variable.

     
  2. 7.

    To add multiple conditions, she could click the Add Condition button.

     
The Delete Records element looks like Figure 6-14.
../images/472313_1_En_6_Chapter/472313_1_En_6_Fig14_HTML.jpg
Figure 6-14

Configuring a Delete Records element

  1. 8.

    When she is finished, Pamela clicks the Done button.

     
  2. 9.
    Now she needs to connect the Delete Records element with the Start element so that, at runtime, Lightning Flow can decide the order of execution of the elements. To do this, in the source element, Pamela finds the node at the bottom and then drags it to the target element (Figure 6-15).
    ../images/472313_1_En_6_Chapter/472313_1_En_6_Fig15_HTML.jpg
    Figure 6-15

    Connecting the flow elements

     
  3. 10.

    Pamela clicks the Save button and enters Delete unqualified leads as the name by which to save the flow.

     
  4. 11.

    Pamela does not forget to activate the flow! She does so by clicking the Activate button.

     

Tip

To learn more about Lightning Flow, refer to this Trailhead module: https://trailhead.salesforce.com/en/content/learn/modules/business_process_automation.

Introduction to Lightning Process Builder

Lightning Process Builder is another way to automate business processes. It is the upgraded version of workflow rules, which don’t have capabilities to post a message on chatter, create a child record on a specific action, autosubmit records for approval, and so on. Process Builder supports these actions.

Lightning Process Builder is much more powerful than a workflow rule. It has the capability to create a record or update the parent record if a lookup relationship exists between the two objects. For example, if you want to automate a process of submitting records into an approval process, without any manual intervention, you can use Process Builder to do so.

Actions Process Builder Supports

Process Builder not only performs almost all activities available in workflow rules, but it also consists of a few new actions. Unfortunately Process Builder doesn’t support outbound messages. You can use Process Builder to perform the following actions:
  • Apex: Use this action to call the Apex class that contains the @InvocableMethod annotation.

  • Create a Record: Use this action to create a record. For example, create a lead when an opportunity is updated as Closed Lost.

  • E-mail Alerts: Use this action to send out e-mail alerts to notify users or customers.

  • Flows: Use this action to call a flow.

  • Post to Chatter: Use this action to post a message on a chatter group, record feed, or on a user’s chatter feed.

  • Processes: Use this action to invoke a process from another process.

  • Quick Actions: Use this action to create a record, update a record, or log a call by using a quick action—either object specific or global.

  • Quip: Use this action to automate Quip documentation. For example, autocreate a Quip document when a new account is created.

  • Send Custom Notification: Use this action to send a custom notification to your users on the Salesforce mobile app or inside Lightning Experience.

  • Send Survey Invitation: Use this action to autosend a survey invitation to customers.

  • Submit for Approval: Use this action to autosubmit a record to an approval process.

  • Update Records: Use this action to update one or more records related to the record that started the process.

When to Use Which Automation Tool

Salesforce provides numerous tools to automate business processes, such as Lightning Flow, workflow rules, and Process Builder. It is vital to understand the differences among these tools and know when to use which tool. Table 6-1 presents the differences among these tools.
Table 6-1

Differences among Automation Tools

 

Workflow Rule

Lightning Flow

Lightning Process Builder

Visual Designer

Not available

Available

Available

Starts when

Record is created or edited

• Manually

• Automatically through Process Builder

• At a specified time

Record is created or edited

Supports time-based actions

Yes

Yes

Yes

Calls Apex code

No

Yes

Yes

Creates records

Only task

Yes

Yes

Updates records

Yes (only fields from the same record or parent, in the case of a master detail relationship)

Yes, any record

Yes, any related record

Deletes records

No

Yes

No

Launches a flow

No

Yes

Yes

Posts to chatter

No

Yes

Yes, only text posts

Sends an e-mail

Yes

Yes

Yes

Submits for approval

No

Yes

Yes

Sends outbound messages

Yes

No

No

Supports user interaction

No

Yes

No

Supports version control

No

Yes

Yes

Supports user input at runtime

No

Yes (using the Screen element)

No

Use Case 3: Call an Autolaunched Flow

Pamela Kline created an autolaunched flow in use case 2. Now she wants to learn how it can be invoked from Process Builder when a lead is marked as unqualified. She performs the following steps to call a flow using Lightning Process Builder:
  1. 1.
    She navigates to Setup (gear icon) ➤ SetupProcess AutomationProcess Builder to create a new process from scratch. Then she clicks the New Button available on the Process Management page. A pop-up appears where she enters the following details:
    1. a.

      Name: She enters the name for the process (Delete unqualified leads pb). Pamela knows the name must be no more than 255 characters.

       
    2. b.

      API Name: This field autopopulates based on the name.

       
    3. c.

      Description: Pamela writes some meaningful text so other developers and administrators can understand easily why this process was created.

       
    4. d.

      The process starts when: She selects A record changes.

       
     
  2. 2.

    When done, she clicks the Save button.

     
  3. 3.
    Next Pamela needs to select the object on which she wants to create a process. To do so, she clicks the Object node, which opens a window where she enters the following details:
    1. a.

      Object: Pamela starts typing and then selects the Lead object.

       
    2. b.

      Start the process: She selects when a record is created or edited.

       
    3. c.
      Allow process to evaluate a record multiple times in a single transaction: Pamela knows that you select this check box only if you want the process to evaluate the same record up to five times in a single transaction. It might reexamine the record because a process, workflow rule, or flow updated the record in the same transaction. Finally, her process looks like Figure 6-16.
      ../images/472313_1_En_6_Chapter/472313_1_En_6_Fig16_HTML.jpg
      Figure 6-16

      Configuring evaluation criteria

       
     
  4. 4.

    When done, she clicks the Save button.

     
  5. 5.
    The next task is to add process criteria so the process always fires when the lead status is unqualified. To define the process criteria, Pamela clicks the +Add Criteria node, which opens a window where she enters the following details:
    1. a.

      Criteria Name: Pamela enters a name for the criteria node. Here, she enters Status = Unqualified as the criteria name.

       
    2. b.

      Criteria for Executing Actions: Here, she can select the type of criteria she wants to define. Pamela can use a formula or filter to define the process criteria, or she could opt for no criteria. In this case, Pamela selects Conditions are met, which means the process will fire when the lead status is unqualified.

       
    3. c.

      Do you want to execute the actions only when specified changes are made to the record? Pamela selects this option because she wants the execution to happen only once, when the condition is met for the first time, not every time a record is edited.

       
     
Finally, her process looks like Figure 6-17.
../images/472313_1_En_6_Chapter/472313_1_En_6_Fig17_HTML.jpg
Figure 6-17

Configuring process criteria

  1. 6.

    When done, she clicks the Save button.

     
  2. 7.

    Next, Pamela must add one immediate action to call an autolaunched flow. To do this, she selects the Flows action available in the Action Type field. She clicks Add Action, which is available under IMMEDIATE ACTIONS, and configures it as shown in Figure 6-18.

     
../images/472313_1_En_6_Chapter/472313_1_En_6_Fig18_HTML.jpg
Figure 6-18

Configuring the Flows action

To select the fields, she could use Field Picker; to enter the value, she could use the Text Entry field.
  1. 8.
    When done, Pamela clicks the Save button. In the end, her process looks like Figure 6-19.
    ../images/472313_1_En_6_Chapter/472313_1_En_6_Fig19_HTML.jpg
    Figure 6-19

    Final version of the process

     
  2. 9.

    Pamela does not forget to activate the process! She does so by clicking the Activate button.

     

The next time a user updates a lead to unqualified, the process Pamela created (using Process Builder) will fire and delete the record.

Use Case 4: Update Child Records

Pamela receives another requirement from her manager: when an opportunity is updated as Closed Lost, update all related quotes to Denied.

There are several ways to meet this requirement:
  • Use an Apex trigger

  • Use a combination of Lightning Flow and Lightning Process Builder

  • Use a combination of Lightning Flow and Inline Visualforce Page on the Opportunity detail page

  • Use Lightning Process Builder

Pamela decides to use Process Builder because it is fast and doesn’t require coding skills. She performs the following steps:
  1. 1.
    She navigates to Setup (gear icon) ➤ SetupProcess AutomationProcess Builder to create a new process from scratch. She clicks the New button available on the Process Management page. A pop-up appears and she enters the following details:
    1. a.

      Name: She enters the process name Update quotes. She knows the name must be no more than 255 characters.

       
    2. b.

      API Name: This field autopopulates based on the name.

       
    3. c.

      Description: Pamela writes some meaningful text so other developers and administrators can understand easily why this process was created.

       
    4. d.

      The process starts when: She selects A record changes.

       
     
  2. 2.

    When done, she clicks the Save button.

     
  3. 3.
    Now Pamela needs to select the object on which she wants to create a process. She clicks the Object node, which opens a window where she enters the following details:
    1. a.

      Object: She starts typing and then selects the Opportunity object.

       
    2. b.

      Start the process: She selects when a record is created or edited.

       
    3. c.

      Allow process to evaluate a record multiple times in a single transaction: Pamela knows that you select this check box only if you want the process to evaluate the same record up to five times in a single transaction. It might reexamine the record because a process, workflow rule, or flow updated the record in the same transaction.

       
     
  4. 4.

    When done, she clicks the Save button.

     
  5. 5.
    The next task is to add process criteria so the process always fires when the lead status is unqualified. To define the process criteria, Pamela clicks the +Add Criteria node, which opens a window where she enters the following details:
    1. a.

      Criteria Name: She enters Stage = Closed Lost as the criteria name.

       
    2. b.

      Criteria for Executing Actions: Here, Pamela can select the type of criteria she wants to define. She can either use a formula or filter to define the process criteria, or she can choose no criteria. In this case, she selects Conditions are met and opts for Stage = Closed Lost, which means the process fires when the opportunity stage is Closed Lost.

       
    3. c.

      Do you want to execute the actions only when specified changes are made to the record? Pamela selects this option because she wants the execution to happen only once, when the condition is met for the first time, not every time a record is edited.

       
     
Finally, her screen looks like Figure 6-20.
../images/472313_1_En_6_Chapter/472313_1_En_6_Fig20_HTML.jpg
Figure 6-20

Configuring process criteria

  1. 6.

    When done, she clicks the Save button.

     
  2. 7.

    Next, Pamela must add one immediate action to call an autolaunched flow. To do this, Pamela uses the Update Records action available in the Action Type field. She clicks Add Action, which is available under IMMEDIATE ACTIONS, and configures it as shown in Figure 6-21.

     
../images/472313_1_En_6_Chapter/472313_1_En_6_Fig21_HTML.jpg
Figure 6-21

Configuring the Update Records action

To select the fields, Pamela can use Field Picker; to enter the value, she can use the Text Entry field.
  1. 8.
    When done, she clicks the Save button. In the end, her process looks like Figure 6-22.
    ../images/472313_1_En_6_Chapter/472313_1_En_6_Fig22_HTML.jpg
    Figure 6-22

    Final version of the process

     
  2. 9.

    Pamela does not forget to activate the process! She does so by clicking the Activate button.

     

The next time a user updates an opportunity to Closed Lost, the process Pamela created (using Process Builder) fires and set quotes to Denied.

Introduction to Approval Processes

Almost every organization uses some sort of approval process. For example, if you want to take a day or two off, you may need to get approval from your manager to do so. An approval process is a way an organization approves anything from invoices, budgets, and purchase orders to a new process the company wants to incorporate. Implementing an approval process can standardize an organization’s internal processes, and also saves time by creating a dependable, repeatable process. Approval processes are a type of workflow, which is any sequence of work from initiation to completion, that you can create to ensure work is approved the same way every time.

The approval process in Salesforce is an automated process used to approve records in Salesforce. You can specify what happens when records are approved or rejected by the approver.

Wizards to Create an Approval Process

Salesforce offers two types of wizards to create approval processes:
  1. 1.

    Jump Start Wizard: Use this wizard to create a one-step approval process. This wizard allows you to create an approval process quickly. Everything is available on the same screen, so a user does not have to navigate through several screens.

     
  2. 2.

    Standard Wizard: Use this wizard to create multistep approval processes. This wizard consists of setup wizards that allow users to define a process, and another setup wizard to allow users to define each step in the process.

     

Once again, Pamela has received a new requirement: create an approval process on the Opportunity object. Approval must be requested from the company’s CEO (Rakesh Gupta) if the opportunity amount is greater than US$5,000,000.

Pamela decides to use the standard wizard to create the approval process on the Opportunity object. Before proceeding, she makes sure she has the Approval Status picklist on the Opportunity object , as shown in Table 6-2.
Table 6-2

Create a Custom Field

Field Type

Label

Length/Values

Picklist

Status

Submitted

Approved

Rejected

Creating a New Approval Process

Pamela performs the following steps in Lightning Experience to create a new approval process on the Opportunity object:

  1. 1.

    She navigates to Setup (gear icon) ➤ All SetupPLATFORM TOOLSProcess AutomationApproval Processes.

     
  2. 2.

    From the Manage Approval Processes For drop-down, she selects the Opportunity object.

     
  3. 3.

    Next, she selects Create new approval process from the drop-down, then selects Use Standard Setup Wizard.

     
  4. 4.
    Then she enters the following information:
    1. a.

      Process Name: Pamela types $5M deal approval process.

       
    2. b.

      Unique Name: This field is autopopulated based on the process name.

       
    3. c.

      Description: Pamela enter a meaningful description of the approval process so other administrators can understand easily why this approval process was created.

       
     
  1. 5.

    When done, she clicks the Next button.

     
  2. 6.

    Now Pamela must specify the entry criteria. When done, her screen looks like Figure 6-23.

     
../images/472313_1_En_6_Chapter/472313_1_En_6_Fig23_HTML.jpg
Figure 6-23

Specifying entry criteria

When done, she clicks the Next button.
  1. 7.
    Now Pamela must define the following actions:
    1. a.

      Select Field Used for Automated Approval Routing: The approval process allows an approval process creator to assign approval requests to any user. Another option is to use a user field to route approval requests automatically. The user field can be any custom hierarchical relationship field, such as Reporting Manager or the manager standard user field. Pamela leaves this as is.

       
    2. b.

      Record Editability Properties: When a record is submitted for approval, it gets locked. The process allows Pamela to define who can edit the record when a record is in the midst of an approval process. She selects the option Administrators OR the currently assigned approver can edit records during the approval process.

       
     
Pamela’s screen looks like Figure 6-24.
../images/472313_1_En_6_Chapter/472313_1_En_6_Fig24_HTML.jpg
Figure 6-24

Specifying the approver and the Record Editability Properties field

When done, she clicks the Next button.
  1. 8.

    When an approval process assigns an approval request to a user, it automatically sends an e-mail notification to the user. The e-mail contains a link to the approval page. If you want to use your custom e-mail template, then choose a template or leave it blank. If you leave it blank, Salesforce uses the default e-mail template. When done, Pamela clicks the Next button.

     
  2. 9.
    On the next screen, Select Fields to Display on Approval Page Layout, Pamela does the following:
    1. a.

      She selects the fields she wants to display on the Approval Request page.

       
    2. b.

      She selects the check box Display approval history information in addition to the fields selected above to display the approval history-related list on the Approval Request page.

       
    3. c.

      In the Security Settings section, Pamela must select the option where users can approve or reject a request. She selects Allow approvers to access the approval page from within the salesforce.com application, or externally from a wireless-enabled mobile device.

       
     
Her screen looks like Figure 6-25.
../images/472313_1_En_6_Chapter/472313_1_En_6_Fig25_HTML.jpg
Figure 6-25

Selecting fields to display on the Approval Request page

When done, Pamela clicks the Next button.
  1. 10.
    Now Pamela must specify the initial submitters (Figure 6-26). She does this as follows:
    1. a.

      In the Submitter Type section, she selects Opportunity Owner.

       
    2. b.

      Then she selects the check box Add the Approval History related list to all Registration page layouts to add the approval history-related list to the Account page.

       
    3. c.

      Pamela then makes sure she selects the check box Allow submitters to recall approval requests. This will allow the submitter to recall the approval process.

       
    ../images/472313_1_En_6_Chapter/472313_1_En_6_Fig26_HTML.jpg
    Figure 6-26

    Specifying initial submitters

     
  2. 11.
    When done, she clicks the Save button. In the next screen, she selects the option No, I’ll do this later, take me back to the listing of all approval processes for this object. The system redirects her to the screen shown in Figure 6-27.
    ../images/472313_1_En_6_Chapter/472313_1_En_6_Fig27_HTML.jpg
    Figure 6-27

    Approval process detail page

     

Final Approval Actions

Final approval happens only when a record has received all the required approvals. For the current scenario, Pamela navigates to the Final Approval Actions section, then clicks the Edit link and selects Unlock the record for editing, as shown in Figure 6-28.
../images/472313_1_En_6_Chapter/472313_1_En_6_Fig28_HTML.jpg
Figure 6-28

Final approval action

When done, she clicks the Save button. She repeats these steps for the Final Rejection and Recall actions.

Initial Submission Actions

The Initial action happens only when a record is initially submitted for approval. When the record is submitted successfully for approval, it gets locked. You can define actions such as Field Update, Email Alert, Assign Task, and Outbound Message. Add one initial submission action to update the Approval Status field to Submitted, as shown in Figure 6-29.
../images/472313_1_En_6_Chapter/472313_1_En_6_Fig29_HTML.jpg
Figure 6-29

Initial submission action

This field update executes when an Opportunity record is submitted for the CEO’s approval.

Approval Steps

Now Pamela needs to add approval steps per the requirement. If you recall, the approval request should go to the CEO (Rakesh Gupta) for approval.

Approval Step 1

The first step is to get the approval from the CEO (Rakesh Gupta). Pamela performs the following actions to achieve this:
  1. 1.

    She navigates to the Approval Steps section then clicks the New Approval Step button.

     
  2. 2.
    Next, she enters the following details:
    1. a.

      Name: Pamela types Approval from CEO.

       
    2. b.

      Unique Name: The unique name is autopopulated based on the name.

       
    3. c.

      Description: Pamela enters a meaningful description of the approval step so other developers and administrators can understand easily why this second approval step has been created.

       
    4. d.

      When done, she clicks the Next button.

       
     
  3. 3.

    Now Pamela needs to filter out records. She decides which record should enter the approval step. She can filter out a record by adding more conditions. For example, suppose she wants to filter the Opportunity record that is refereed by partners. For this scenario, she would select All records should enter this step, then click the Next button.

     
  4. 4.
    In the next screen, Pamela selects UserRakesh Gupta. Her screen now looks like Figure 6-30.
    ../images/472313_1_En_6_Chapter/472313_1_En_6_Fig30_HTML.jpg
    Figure 6-30

    Selecting an assigned approver

     
  5. 5.

    When done, she clicks the Save button.

     
  6. 6.

    On the next screen she selects the option No, I'll do this later. Take me to the approval process detail page to review what I've just created. Pamela is then redirected to the approval process detail page.

     
  7. 7.

    Now she adds field updates to the Approval Actions and Rejection Actions sections to update the Status field to Approved or Rejected, as shown in Figure 6-31.

     
../images/472313_1_En_6_Chapter/472313_1_En_6_Fig31_HTML.jpg
Figure 6-31

Field updates to show Approval or Rejection actions

Pamela has now created a multistep approval process. She can view the process diagram of the approval process by clicking View Diagram.

Activating an Approval Process

Pamela knows she has to activate the approval process by clicking the Activate button at the top of the approval process page, as shown in Figure 6-32.
../images/472313_1_En_6_Chapter/472313_1_En_6_Fig32_HTML.jpg
Figure 6-32

Activating an approval process

Before activating it, however, she makes sure no more changes are required, because once an approval process is active, it is not possible to add more steps to it.

Points to Remember

  1. 1.

    Users with the Flow User permissions on their user record. And, Run Flow or Manage Flow permissions on their profile, or via a permission set, a user can run Flow.

     
  2. 2.

    To activate a process, it must have an action added to it.

     
  3. 3.

    Process Builder doesn’t have an option to delete records. If you want to do so, you must use a combination of Lightning Flow and Process Builder.

     
  4. 4.

    The process/flow owner, or last modified user, receives an e-mail from Salesforce if the process fails during runtime or if any other fault occurs. Use the Apex Exception Email option to distribute such errors to other users.

     
  5. 5.

    A process has same the governing limits as that of Apex.

     
  6. 6.

    Process actions are executed in the same order in which they appear in the process.

     
  7. 7.

    You can’t delete an active process. If you want to do so, you must first deactivate it.

     
  8. 8.

    If you leave the Next Automated Approver Determined By field blank, you can’t assign approval requests automatically to the manager in any step you create for an approval process.

     
  9. 9.

    You can use Process Builder to autosubmit the record into an approval process.

     
  10. 10.

    Use the Mass Transfer Approval Requests wizard to “mass-transfer” pending approval requests from one user to another user.

     
  11. 11.

    You can create and run approval history reports to check in-progress and completed approval processes and their steps.

     

Hands-on Exercises

The following exercises will give you more practice with the platform, which ultimately will help you in gaining mastery of it, and also will assist you in preparing for the certification examination. Remember, these are hands-on exercises, and you can find the answers at the back of the book in the Appendix, but try to implement them in your Salesforce org, which is the primary goal of doing them. Try to do the exercises without looking at the answers!
  1. 1.

    Create a flow that displays three number fields: First Number, Second Number, and Third Number. On the next screen, show the summation of the values in these fields.

     
  2. 2.

    Dennis Williams, a system administrator at GoC, receives a requirement to send a welcome e-mail to new customers (contacts) as soon as a user is created in Salesforce. How would you instruct him to meet this requirement?

     
  3. 3.

    Dennis Williams receives another requirement to keep the contact’s phone number in sync with the account’s Phone Number field. This means, whenever someone updates a phone number on an account, it should be reflected in the contact’s record. How would you instruct him to meet this requirement?

     
  4. 4.
    Dennis wants to implement opportunity management at GoC, but he is a bit confused by one of the requirements. Because you now have a better understanding of process automation, please help him automate the business process for the following requirements:
    1. a.

      When an opportunity amount is greater than $1,000,000, create a post on the chatter group Key Deals.

       
    2. b.

      Whenever an opportunity is marked Closed Won, autoupdate the account description to We won another deal!

       
    3. c.

      Whenever an opportunity is marked Closed Won, notify the opportunity team on Salesforce mobile and in Lightning Experience.

       
     
  5. 5.

    Dennis Williams receives a requirement to add the permission set View All Leads automatically to new users. How would you instruct him to meet this requirement?

     

Summary

In this chapter, we covered Lightning Flow, and Lightning Flow Designer and its life cycle. We also went through different use cases of Lightning Flow. Furthermore, we reviewed Lightning Process Builder via a few examples. Last, we studied approval processes and how to configure them by looking at an example. In Chapter 7, we examine the application development life cycle. So, stay tuned!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.208.200