Chapter 8. Automating Complex Business Processes

In the previous chapters, we discussed the overview of Visual Workflow. We also talked about the benefits of using Visual Workflow and a few use cases where we can use it. We also learned the way of setting up an approval process. This chapter starts with an overview of the Process Builder. We will take the discussion forward to discuss the difference between various automation tools and when to use what. Then, we will go through step-by-step instructions to create a process using Process Builder. The following topics will be covered in this chapter:

  • Process Builder overview
  • Difference between Process Builder and other tools
  • Auto-creating a child record
  • Auto-updating child records
  • Posting messages to a Chatter group
  • Auto-submitting records into the approval process

Process Builder overview

Process Builder is an alternate way of automating your business processes by writing code. It is an advanced version of the Workflow Rule. Process Builder is created on top of Visual Workflow and Flow Trigger (Deprecated). Whenever you create a process by using the Process Builder, it will automatically create a Flow and a Flow Trigger (Deprecated) to call this Flow; this happens behind the scenes and users don't need to interact with these Flows.

Workflow Rule comes with several limitations, for example, it doesn't have an action to update child records, post to Chatter, and create a child record. Process Builder is available for the Lightning Enterprise, Lightning Unlimited, and Developer editions. It is also available for the Lightning Professional edition with a few limitations, for example, you can only have five active processes in the Lightning Professional edition. There are a few advantages of Process Builder, as follows:

  • You can define the complete process in a single screen, unlike Workflow Rule where you have to move from screen to screen to create a complete rule
  • It allows you to create the complete process using point-and-click
  • By using it, you can minimize Apex code usage in your Salesforce org
  • It is also possible to call an Apex class from a process

Business problems

As a Salesforce administrator or developer, you may get various requirements from the business to streamline the internal sales or support processes. As per our experience, we can say that many of them are achievable by using out-of-the box (OOB) features, and for a few, we must use Apex or Visualforce Page. Visual Workflow gives us another way of implementing various business processes without using Apex or Visualforce Page. The following are a few examples of it, explained in further subsections.

Business use case

A business scenario: David Guzman is working as a system administrator at Universal Containers. He has received a requirement to auto-add new users to a Chatter group, Universal Containers Notice Board.

There are several ways to solve the preceding business requirement; a few of them are mentioned in the subsequent subsections.

Solution 1 - using an Apex trigger

As the requirement is to add new users to a Chatter group, we can't use Workflow Rule to achieve it. One possible solution is to write an Apex trigger on a user object to add new users to the Chatter group, Universal Containers Notice Board, as soon as the user gets created.

The following is the sample code:

trigger AutoAddNewUsertoChatter Group on User (after insert) { 
List<CollaborationGroup> chatterGroups=[select id, Name from CollaborationGroup where name =' Universal Containers Notice Board]; 
  for(user user: Trigger.new) 
            {                 
               //your logic 
            } 
} 

Solution 2 - using an Apex trigger

Another way to achieve the same business requirement is to create a process by using the Process Builder. Check out the following screenshot:

Solution 2 - using an Apex trigger

Here is the description for the preceding screenshot:

  • A sample process on user object; it will only trigger at the time of user creation
  • Add one schedule action; it will trigger after 0 hours of user creation
  • Then, add a quick action to add new users to the Chatter group, Universal Containers Notice Board

Process Builder is another way to automate business processes using click not code. To deploy a process in production org, you don't need to write a test class for it.

Overview of Process Builder user interface

The Process Builder is a point-and-click wizard that allows you to completely automate a business requirement by creating a process. It has almost all the features offered by Workflow Rule, including a few extra features such as post to Chatter, call a Flow, create a record, and more. The Process Builder user interface has different functional parts, as follows:

Overview of Process Builder user interface

  1. Button Bar: The following are the buttons available in the Button Bar.
    1. Activate: Use this button to activate a process. You can't make any changes once a process is activated.
    2. Deactivate: This button is only available if a process is activated. Use this button to deactivate a process.
    3. Edit properties: It will show you Name, API Name, and Description of your process. It allows changing the process name and description till the process is not activated. However, you can't change API Name after you have saved it for the first time.
    4. Clone: The cloud Flow designer has a Save As button to either save a Flow as New Version or create a New Flow. Likewise, Process Builder has a Clone button for the following activities:
      • The version of the current process
      • New process

        Overview of Process Builder user interface

    5. View All Processes: Once you click on this button, it will redirect you to the Processes Management page. On the Process Management page, it will display all the processes.
    6. Collapse All: Collapse actions on the process canvas.
    7. Expand All: Expand actions on the process canvas.
  2. Process Canvas: This is the point-and-click area to develop a process. To edit any element in the process canvas, double-click on it.
  3. Add Object: Choose the object on which you want to create a process and choose Evaluation Criteria.
  4. Add Criteria: Use this to define the entry criteria and set the filter conditions.
  5. Immediate Actions: Use this to define immediate actions for the process.
  6. Scheduled Actions: Use this to define scheduled actions for the process.

Actions available in Process Builder

Process Builder can perform almost all actions that are available for Workflow Rule and it also contains a few extra actions, but it doesn't support outbound messages. With Process Builder, you can perform the following actions:

  1. Apex: Using this action, you can call an Apex class that contains an invocable method.
  2. Create a Record: Using this action, you can create a record.
  3. Email Alerts: Using this action, you can send out an e-mail alert.
  4. Flows: Using this action, you can call a Flow from a process.
  5. Post to Chatter: Using this action, you can post TextPost on Chatter group, Record, or User Chatter profile.
  6. Processes: Using this action, you can invoke another process.
  7. Quick Actions: Using this action, you can use object-specific or global actions to create a record, update a record, or log a call.
  8. Submit for Approval: Using this action, you can auto-submit a record into Approval Process.
  9. Update Records: Using this action, you can update any related records.
..................Content has been hidden....................

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