Salesforce Process Builder Quick Start Guide

By Rakesh Gupta
  • Instant online access to over 7,500+ books and videos
  • Constantly updated with 100+ new titles each month
  • Breadth and depth in over 1,000+ technologies

About this book

Salesforce Management System is an information system used in CRM to automate business processes, such as sales and marketing. Process Builder is a visual tool created to automate business processes in Salesforce. It enables users with no coding expertise to build complex Salesforce workflows.

The book starts with an introduction to Process Builder, focussing on the building blocks of creating Processes. Then you will learn about different applications of Process Builder for developing streamlined solutions. You will learn how to easily automate business processes and tackle complex business scenarios using Processes. The book explains the workings of the Process Builder so that you can create reusable processes. It also explains how you can migrate existing Workflow Rules to Process Builder.

By the end of the book, you will have a clear understanding of how to use Flows and Process Builder to optimize code usage.

Publication date:
July 2018
Publisher
Packt
Pages
170
ISBN
9781789344318

 

Chapter 1. Getting Started with Lightning Process Builder

This chapter will start with an overview of Process Builder and its benefits, followed by an illustration of how to use Process Builder to automate various business processes. By the end of the chapter, you will have learned how to use Lightning Process Builder's tools and many of its different elements.

In the next chapter, you will be briefed on various tips and tricks related to Process Builder, including how to debug and distribute a Process. You will also see different ways to streamline a sales process and to automate a business process. In the last chapter, we will go over how to create reusable processes using Process Builder, how to bypass Process Builder for a set of users, and much more.

The following topics will be covered in this chapter:

  • An overview of Process Builder
  • The differences between Process Builder and other tools
  • Creating applications with Process Builder
  • Various use cases of Process Builder
  • Limitations of Process Builder

Just to remind you, we will use Lightning Experience for all chapters.

 

An overview of Process Builder


Lightning Process Builder and Process Builder are the same tool. Process Builder provides a way to automate business processes. In other words, it is the upgraded version of the Workflow Rule. Whenever you create a process, the system automatically creates a Flow, and a Flow Trigger to call the Flow. This happens behind the scenes, and the user doesn't need to interact with the shadow Flows. The Workflow Rule has several limitations. It doesn't allow you to update child records. Also, it doesn't allow you to post to Chatter, create a child record on a specific action, or automatically submit a record for approval.

To overcome these limitations, Salesforce introduced Process Builder in its Spring 2015 release. There are a few advantages to Process Builder, which are as follows:

  • It allows you to create a complete process on a single screen, unlike in Workflow Rules, where you have to move from screen to screen to create a complete rule.
  • Its visual layouts allow you to create a complete process using point-and-click.
  • It helps you to minimize Apex code usage.
  • It allows you to call Apex from Process Builder, where Apex is still required.
  • It also allows you to create multiple scheduled actions for the criteria from Process Builder.
  • You can easily reorder process criteria with drag and drop.
  • It is also possible to execute multiple criteria of a process.

As of the Summer 2018 release, Process Builder runs in system mode, so object- and field-level permissions will be ignored for the user that triggers the process. Visual Workflow runs in user mode, which means that at runtime, the user that triggers the Flow, their access on the object, and field the level will be counted. However, if a process is launching a Flow, the whole automation will run in system mode. Let's look at an example; suppose that you are trying to update the opportunity Next Step field:

  1. If you are using Process Builder: If the running user doesn't have access to the Next Step field, Process Builder will be able to update it.
  2. If you are using Flow (a custom button to call a Flow): If the running user doesn't have access to the Next Step field, they will get an error.
  3. If you are using Flow to achieve the same thing, and you are using Process Builder to auto-launch the Flow: If the running user doesn't have access to the Next Step field, then the Flow will be able to update it.

If any of the actions fail at runtime, the entire transaction will fail, and an error message will be displayed. There are some exceptions to this and settings to work around it, which we will discuss inChapter 2, Deploying, Distributing and Debugging your Process. 

Business problems

As a Salesforce administrator or developer, you may receive multiple requirements from a business, to streamline sales or support processes. If something can't be achieved using Workflow Rule, then you may have to use Apex code to automate it. Let's look at a business scenario.

The use case is as follows: Sara Bareilles is working as a Salesforce administrator at Universal Containers. She has a requirement to auto-update the related contactsOther Phone field with the account Phone, once the account has been activated.

There are several ways to fulfill the preceding business requirement:

  1. To fulfill this business requirement, we could create a Flow and embed it in a Visualforce page. Then, we could use it as an inline Visualforce page in an account page layout.
  2. Since we can't achieve the business requirement using a Workflow Rule, the next possibility is to use an Apex trigger. A developer writes an Apex trigger on an Account object, to update all contacts when the account is activated.
  3. You can also use Process Builder. We will discuss that in detail later in this chapter.

Browser requirements for Process Builder

Process Builder is available for Lightning Essentials and Professional (with a limited number of processes), Lightning Enterprise, Lightning Unlimited, and Lightning Developer editions. You can access Process Builder on any platform. The requirements are as follows:

  • The most recent version of Google Chrome
  • The most recent version of Mozilla Firefox
  • The most recent version of Safari
  • The most recent version of Internet Explorer

Process Builder is 508-compliant, which means that all users, regardless of disability status, can access Process Builder, with one exception:

They can close modal dialogs using the ESC key on their keyboard, but they can’t close side panels by using the ESC key.

An overview of the Process Builder user interface

Process Builder is a tool that allows you to implement business requirements by creating processes (without any code). It has almost all of the features that are offered by Workflow Rule, and it also contains some new features, such as Post to Chatter, Launch a Flow, Create a Record, Update Records, and Submit for Approval. From now on, we will use Lightning Experience to create or manage processes using Process Builder, and to create or manage Visual Workflows. The Process Builder user interface has different functional parts, which are shown in the following screenshot:

The different functional parts of the user interface of Process Builder are as follows:

  1. Button bar: The following are the buttons available in the button bar:
    • Activate: Use this button to activate your process. You can't make any changes once a process is activated.
    • Deactivate: This button is available on the button bar only if the process is activated. Use this button to deactivate a process.
    • Edit Properties: This will show you the Process Name, API Name, and Description fields of your process. It allows you to change the process name and description, as long as the process is not activated. You can't change the API Name field after you've saved it for the first time. The Properties window will look as follows:
    • Clone: The Clone button lets you make a copy of the current process. You will be given two Clone As options – Version of current process and A new process.
    • View All Processes: When you click on this button, it will redirect you to the Processes Management page. From there, you can see all of the processes created in the current Salesforce organization.
    • Collapse All: Collapse all actions on the canvas.
    • Expand All: Expand all actions on the canvas.
  1. Process canvas: This is the main area, where you can use point-and-click to develop a process. To edit any element on the process canvas, double-click on it.
  2. Add object: Select the object upon which you want to create a process, and choose the evaluation criteria (the changes that will cause the process to run).
  3. Add criteria: Use this to define the criteria and set the filter conditions.
  4. IMMEDIATE ACTIONS: Use this to define immediate actions for the process.
  5. SCHEDULED ACTIONS: Use this to define scheduled actions for the process.

Actions available in Process Builder

Process Builder can perform almost all of the actions that are available for Workflow Rules, and it also contains some new actions. It doesn't support outbound messages, among other things. With Process Builder, you can perform the following actions:

  • Apex: This allows you to call an Apex class that contains an invocable method.
  • Create a Record: Using this, you can create a record.
  • Email Alerts: Use this to send email alerts.
  • Flows: Use this action to call a Flow from the Process.
  • Post to Chatter: Use this to post a textpost on a Chatter group, a record, or a user's wall.
  • Processes: Use this action to call an existing process from another process.
  • Quick Actions: Use this action to call a Chatter global action or object specific action; for example, log a call, create a record, and so on.
  • Submit for Approval: Use this action to submit a record to an Approval Process.
  • Update Records: This allows you to update any related records.

In this and the following chapters, we will see each action in detail.

 

Differences between Process Builder and other tools


Salesforce offers various tools to automate business processes; for example, Visual Workflow, Workflow Rule, and Process Builder. So, it is necessary to understand the differences between these tools, and when to use which one. The following table describes the differences between these tools:

Workflow

Flow

Process Builder

Visual designer

Not available

Available

Available

Starts when

A record is created or edited

  • The user clicks on a custom button/link
  • A process starts
  • Apex is called
  • Inline Visualforce page
  • The user accesses a custom tab

A record is created or edited

Supports time-based actions?

Yes

Yes

Yes

Call Apex code?

No

Yes

Yes

Create records

Only task

Yes

Yes

Invoke processes

No

No

Yes

Update records?

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

Yes, any record

Yes, any related record

Delete records?

No

Yes

No

Launch a Flow?

No

Yes

Yes

Post to Chatter?

No

Yes

Yes, but only textpost

Send an email?

Yes

Yes

Yes

Submit for approval?

No

Yes

Yes

Send outbound messages?

Yes

No

No

Supports user interaction?

No

Yes

No

Version control?

No

Yes

Yes

Supports user input at runtime?

No

Yes (through screen elements)

No

Supports unauthenticated access?

No

Yes (through Force.com sites)

No

Can pause on runtime?

No

Yes

No

Allows modification

After deactivation, you can modify the Workflow Rule

Once Flow is activated, you can't modify it, and the same applies after deactivation

Once process is activated, you can't modify it, and the same applies after deactivation

Delete

Once Workflow is deactivated, you can immediately delete it

Once Flow is deactivated, you can immediately delete it

Once process is deactivated, you can immediately delete it

Version Control

No

Yes (number of versions you can create for a Flow is 50)

Yes (number of versions you can create for a process is 50)

 

Creating applications with Process Builder


Before Process Builder was available, knowledge of Apex and Visualforce was required to automate complex business processes in Salesforce. After completing this chapter, you will have a clear idea of how to automate business processes using Process Builder, and will minimize your need for Apex code. Now, we will discuss how to use Process Builder to automate business processes. From now on, we will use Lightning Experience to create or manage processes using Process Builder, and to create or manage Visual Workflows.

Hands on 1 – auto-create a child record

Businesses commonly require the auto-creation of a child record whenever a parent record gets created. For example, as soon as an account gets activated, we need to auto-create an opportunity for that account, and we need to set the opportunity close date to the last date of the current quarter. To satisfy this type of business requirement, a developer normally writes an Apex trigger, but there are a few other ways to achieve it, without writing code:

  • Using Process Builder
  • Using a combination of Flow and Process Builder
  • Using a combination of Flow and an Inline Visualforce page, on the account detail page

We will use Process Builder to solve this business requirement.

Let's consider a business scenario. Suppose that Joe Thompson is working as a system administrator at Universal Containers. He has received a requirement from the management to auto-create a contract as soon as an account gets created in Salesforce, and to auto-populate these values in the new contract:

  • Contract term (months): 12
  • Contract start date: Account created date, + 90 days
  • Status: Draft
  • Auto-relate it with a new account

Creating a process

To solve the preceding business requirement, we will use Process Builder. In the runtime process, we will auto-create a contract record whenever a new account record gets created. To do this, follow these instructions:

  1. In Lightning Experience, click on Setup (gear icon) | Setup | PLATFORM TOOLS | Process Automation | Process Builder; click on the New button, and enter the following details:
    • Process Name: Enter the name of the process. Enter Auto create new Contract as the Process Name. It must be within 255 characters.
    • API Name: This will be auto-populated, based on the name. It must be within 77 characters.
    • Description: Write some meaningful text, so that other developers or administrators can easily understand why this process was created.
    • This process starts when: This allows you to select when you want to start your process. The following options are available:
      • A record changes: Select this option if you want to start your process when a record is created or edited.
      • It's invoked by another process: Select this option if you want to invoke your process from another process. This allows you to create an invocable process. An invocable process is a process that starts when another process invokes it. In Chapter 3, Building Efficient and Performance-Optimized Processes, we will discuss a few use cases in detail.

In this case, select A record changes. The fields should appear as follows:

  1. Click on the Save button when you have finished. It will redirect you to the process canvas, which will allow you to create the process by clicking, not code.

Adding an object and evaluation criteria

Once you are done defining the process properties, the next task is to select the object upon which you want to create a process and define the evaluation criteria:

  1. Click on the Add Objectnode, as shown in the following screenshot:
  2. This will open a window on the right-hand side, where you will have to enter the following details:

    • Object: Start typing, and then select theAccountobject.
    • Start the process: For Start the process, select only when a record is created. This means the process will fire only at the time of record creation.
    • Recursion – Allow process to evaluate a record multiple times in a single transaction?: Select this checkbox only when 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 may have updated the record in the same transaction. In this case, leave the box unchecked. The window should appear as shown in the following screenshot:
  1. Once you are done, click on the Save button. Just as in Workflow Rule, once you have saved the panel, it doesn't allow you to change the selected object.

Adding process criteria

After defining the evaluation criteria, the next step is to define the process criteria. This is similar to the rule criteria in Workflow Rule. Once the process criteria are true, the process will execute with the associated actions:

  1. To define the process criteria, click on the Add Criteria node, as shown in the following screenshot:
  1. Now, enter the following details:
    • Criteria Name: Enter a name for the criteria node. Enter Always in Criteria Name.
    • Criteriafor Executing Actions: Select the type of criteria that you want to define. You can select Formula evaluates to true, or Conditions are met (a filter to define the process criteria), or No criteria-just execute the actions! In this case, select No criteria-just execute the actions! This means that the process will fire for every condition. The window should look as follows:
  1. Once you are done, click on the Save button.

Adding an action to a process

Once you are done with the process criteria node, the next step is to add an immediate action to create a contract. For this, we will use the Create a Record action, available in Process Builder. You can add multiple immediate and scheduled actions for a particular criteria node. The only limitation is the maximum number of criteria nodes that you can add in one process, which is 200. Immediate actions are executed as soon as the evaluation criteria are met.

Scheduled actions are executed at a specified time. We will add an immediate action with the following steps:

  1. We need to add one immediate action to auto-create a record. For this, we will use the Create a Record action, available in Process Builder. Click on Add Action, available under IMMEDIATE ACTIONS, as shown in the following screenshot:

  1. Now, enter the following details:

    • Action Type: Select the type of action. In this case, selectCreate a Record.
    • Action Name: Enter Create Contract record in Action Name.
    • Record Type: Select the object that you want to create a record for. Start typing, and then select the Contract object.
    • Set Field Values: Certain fields are required when you create a record. When you select the object that you want to create a record for, Process Builder automatically displays the required fields for that record in each row. In this case, a row for Account ID and Status shows automatically. When setting a value for a given field or a field you have added, the available value types are filtered, based on the field that you have selected. The available value types are:
      • Currency: You can manually enter a currency value.
      • Boolean: This allows you to choose a true or false Boolean value.
      • DateTime or Date: You can manually enter a DateTime or Date value.
      • Formula: You can easily create a formula, using functions and fields.
      • Global Constant: This allows you to choose a global constant to set a value to null or an empty string. For example, choose $GlobalConstant.Null or $GlobalConstant.EmptyString
      • ID: You can manually enter a Salesforce ID.
      • MultiPicklist: This allows you to choose one or more multi-select picklist values.
      • Number: You can manually enter a number value.
      • Picklist: This allows you to choose a picklist value.
      • Reference: This allows you to choose a value, based on a field on the record or on a related record.
      • String: You can manually enter a string value.

To select the fields, you can use field picker. To enter the values, use the text entry field and map the fields according to the following screenshot:

Use the formula to set the Contract Start Date dynamically, based on the preceding requirement; in this case, you should use the account created date + 90 days. Use Function to select DATEVALUE (it returns a date value for a DateTime), use the Field picker to select the Created Date field, use Operator to select +, and then enter 90, as shown in the following screenshot:

The new record'sCreated Byfield is set to the user that started the process by creating or editing a record.

  1. Once you are done, click on the Save button to save the process's immediate action. The process will appear, as shown in the following screenshot:

Activating a process

As soon as you are done with the process creation, the next step is to activate it:

  1. To activate a process, click on the Activate button, available on the button bar, as shown in the following screenshot:
  1. A warning message will appear on the screen. Read it carefully, and then click on the Confirm button, as shown in the following screenshot:
  1. When you click on the Confirm button, it will activate the process.

For activation, a process must have an action added to it. If a process doesn't have an action added to it, the activate button won't be clickable. After the activation of a process, it's impossible to make any changes to it. If you want to do that, you will have to clone the process, and save it as either a New Version or a New Process, which we will discuss later:

From now on, if you create a new account, you will see a contract created for the account by the process you made, as shown in the preceding screenshot.

Deactivating a process

If some active processes are no longer required by the business, you can deactivate them. To deactivate an activated process, open the process and click on the Deactivate button, as shown in the following screenshot:

After deactivation, Salesforce stops using the process to evaluate when an account record is created or edited. After you deactivate a process, any scheduled actions will still be there, in a queue for execution.

Deleting a process version 

If a process version is no longer in use, you can delete it. You can only delete those process versions that are in the Draft, Inactive, or Invalid Draft status. This means that you can't delete an active process. If you want to delete an active process version, you must deactivate it first, and then delete it. If a process version has scheduled actions, then you can't delete it; in such a case, you must wait until those pending actions have been completed or deleted. To delete a process, follow these instructions:

  1. Navigate to Setup (gear icon) | Setup | PLATFORM TOOLS | Process Automation | Process Builder.
  2. This will redirect you to the Process Management page. Click on the name of the process whose version you want to delete.
  3. Identify the process version that you want to delete, and click on Delete, as shown in the following screenshot:

If your process has only one version and you delete that version, the whole process will be removed from the Process Management page.

Hands on 2 – auto-update child records

There may be business use cases wherein a customer will want to update child records based on some criteria; for example, auto-updating all related opportunities to Closed Lost, if an account is updated to inactive. To achieve these types of business requirements, you can use an Apex trigger. You can also achieve these types of requirements using the following methods:

  • Process Builder.
  • A combination of Flow and Process Builder.
  • A combination of Flow and the Inline Visualforce page, on the account detail page.

We will use Process Builder to solve these types of problems.

Let's look at a business scenario. Suppose that Alice Atwood is working as a system administrator at Universal Containers. She has received a requirement that once an account gets activated, the account Phone must be synced with the related contact Asst. Phone field. This means that whenever an account Phone field gets updated, the same phone number should be copied to the related contact's Asst. Phone field.

Follow these instructions to achieve the preceding requirement using Process Builder:

  1. First of all, navigate to Setup (gear icon) | Setup | PLATFORM TOOLS | Objects and Fields | Object manager | Fields & Relationships, and make sure that the Active picklist is available in your Salesforce organization. If it's not available, create a custom Picklist field with the name Active, and enter the Yes and No values.
  2. To create a process, navigate to Setup (gear icon) | Setup | PLATFORM TOOLS | Process Automation | Process Builder, click on the New button, and enter the following details:

    • Process Name: Enter Update Contacts Asst Phone in Process Name.
    • API Name: This will be auto-populated, based on the name.
    • Description: Write some meaningful text, so that other developers can easily understand why this process was created.
    • This process starts when: Configure the process to start when a record is created or edited. In this case, select A record changes.

The properties window will look as follows:

  1. Once you are done, click on the Save button. It will redirect you to the process canvas, which will allow you to create or modify the process.
  2. After defining the process properties, the next task is to select the object upon which you want to create a process and define the evaluation criteria. For this, click on the Add Object node. It will open an additional window on the right-hand side of the process canvas screen, where you will have to enter the following details:
    • Object: Start typing, and then select the Account object.
    • Start the process: For Start the process, select when a record is created or edited. This means that the process will fire every time, irrespective of record creation or update.
    • Recursion - Allow process to evaluate a record multiple times in a single transaction?: Select this checkbox only when you want the process to evaluate the same record up to five times in a single transaction. In this case, leave the box unchecked. The window will appear as shown in the following screenshot:

 

  1. Once you are done, click on the Save button.
  2. After defining the evaluation criteria, the next step is to add the process criteria. Once the process criteria are true, the process will execute the associated actions. To define the process criteria, click on the Add Criteria node. It will open an additional window on the right-hand side of the process canvas screen, where you will have to enter the following details:
    • Criteria Name: Enter Update Contacts in Criteria Name.

    • Criteria for Executing Actions: Select the type of criteria that you want to define. You can select either Formula evaluates to true, or Conditions are met (a filter to define the process criteria), or No criteria-just execute the actions! In this case, select Conditions are met.

    • Set Conditions: This field lets you specify which combination of the filter conditions must be true for the process to execute the associated actions. In this case, select Active as Yes. This means that the process will fire only when the account is active.

    • Conditions: In the Conditions section, select All of the conditions are met (AND). This field lets you specify which combination of the filter conditions must be true for the process to execute the associated actions.

    • Under Advanced, select Yes to execute the actions only when the specified changes are made. This means that the actions will be executed only if the record meets the criteria now but the values that the record had immediately before it was saved didn't meet criteria. This means that these actions won't be executed when irrelevant changes are made. For example, if the account status is Active and a user updates the record by adding a Shipping Address, the process won’t execute the associated actions. This setting isn’t available if:

      • Your process starts only when a record is created.

      • Your process starts when a record is created or edited, and the criteria node doesn’t evaluate any criteria.

      • The criteria node evaluates a formula, but the formula doesn’t include a reference to the record that started the process.

      • Your process uses the Is changed operator in a filter condition.

In this case, leave the box unchecked. At the end of the process criteria, a window will appear, as shown in the following screenshot:

  1. Once you are done, click on the Save button.

  2. Once you are done with the process criteria node, the next step is to add an immediate action to update the related contact's Asst. Phone field. For this, we will use the Update Records action, available in Process Builder. Click on Add Action, available under IMMEDIATE ACTIONS. It will open an additional window on the right-hand side of the process canvas screen, where you will have to enter the following details:

    • Action Type: Select the type of action. In this case, select Update Records.

    • Action Name: Enter a name for the action. Enter Update Asst. Phone in Action Name.

    • Record Type: Select the record (or records) that you need to update. Click on the Record type; it will pop up a window, where you will see the following options:

      • Select the Account record that started your process.

      • Select a record related to the Account.

      • These are radio buttons, and only one can be selected to update the child record. In this case, choose Select a record related to the Account. Then, in the Type to filter list, look for the child object, Contacts, as shown in the following screenshot:

    • Criteria for Updating Records: Optionally, you can specify conditions to filter the records you are updating. Select No criteria—just update the records! There are cool use cases around it, which we will discuss in Chapter 3, Building Efficient and Performance-Optimized Processes.

    • Field: Map the Asst. Phone field with the [Account].Phone field. 

Select the Contacts object, and then click on the Choose button. To select the fields, you can use the field picker. To enter the value, use the text entry field. It will appear as follows:

  1. Once you are done, click on the Save button.

  2. The final step is to activate the process. Click on the Activate button, available on the button bar. Finally, the process will appear, as shown in the following screenshot:

From now on, if users try to update the Phone field of an active account, the process will automatically update the related contact's Asst. Phone field with the value available in the account's Phone field, as shown in the following screenshot:

Before testing the process, make sure that you have activated it.

Hands on 3 – cloning a process

Once you have activated a process, it doesn't allow you to make any changes to it. If you want to make any changes to an active process, you have to clone it and save it as either a New Version or a New Process.

Let's look at a business scenario. Suppose that Alice Atwood is working as a system administrator at Universal Containers, and she has created a process (Update_Contacts_Asst_Phone) to update the related contact's Asst. Phone field from the account's Phone field, once an account gets activated and after that related contacts Asst. Phone field must be synced with account Asst. Phone field. She has received another request from the business, saying that they want to add one more condition to the process. The entry criteria are such that the condition will work only for accounts wherein the billing country is the USA.

To meet this business requirement, you will have to add one more condition to the existing process. For this, you will have to modify your process. As the process is already activated, the only possibility is to clone it. To clone a process, follow these instructions:

  1. Click on the Clone button, available on the button bar. It will open a popup for you. Under Save As, select the appropriate options:
  2. From the Process Management page, click on the process that you want to modify. It will redirect you to the process canvas page:
    • Version of current process: This allows you to create a new version of an existing process.
    • A new process: If you want to create a new process, select this option.

In this case, select Version of current process to create a new version of an existing process, as shown in the following screenshot:

  1. Click on theSavebutton when you are done.
  2. Now, you can modify the process as per the preceding business requirement, as follows:

The business requirements will appear, as shown in the preceding screenshot. Once you are done, click on the Activate button to activate the current version of the process. Salesforce automatically deactivates others active versions of the current process, if any exist.

Adding an Apex plugin to your process

Process Builder allows you to call an Apex class that includes methods annotated with @InvocableMethod. You can also pass the required value in Apex class variables:

To do this, select the Apex action in the process. In Chapter 3, Building Efficient and Performance-Optimized Processes, we will discuss a use case wherein the system can auto-delete open cases when an account is out of business, using an Apex class and calling it from Process Builder.

Hands on 4 – posting opportunity details to the Chatter group

Often, a business will want to auto-post the details of records to Chatter groups. This is possible through Apex code, but there is a way to achieve it without code – that is, Process Builder. Process Builder has a specific action for this, called Post to Chatter. You can auto-post the record details to a Chatter group using the following methods:

  • Process Builder
  • A combination of Flow and Process Builder
  • A Flow and an Inline Visualforce page

Let's look at a business scenario. Suppose that Helina Jolly is working as a system administrator at Universal Containers. She has received a requirement to post opportunity details to the Sales Executive Chatter group, whenever an opportunity gets created with an amount greater than $1,000,000.

Follow these instructions to achieve this using Process Builder:

  1. Create a public Chatter group, named Sales Executive.

  1. To create a process, navigate toSetup (gear icon) |Setup|PLATFORM TOOLS|Process Automation|Process Builder, click on theNewbutton, and enter the following details:
    • Name: EnterPost Opportunity Information to Chatter Group
    • API Name: This will be auto-populated, based on the name
    • Description: Write some meaningful text, so that other developers or administrators can easily understand why this process was created
  2. Once you are done, click on the Savebutton. This will redirect you to the process canvas, which will allow you to create or modify the process.
  1. After defining the process properties, the next task is to select the object upon which you want to create a process and define the evaluation criteria. For this, click on the Add Object node. It will open an additional window on the right-hand side of the process canvas screen, where you will have to enter the following details:
    • Object: Start typing, and then select theOpportunityobject.
    • Start the process: ForStart the process, selectonly when a record is created. This means that the process will fire only at the time of record creation.
    • Recursion – Allow process to evaluate a record multiple times in a single transaction: Select this checkbox only when you want the process to evaluate the same record up to five times in a single transaction. In this case, leave the box unchecked.
  2. Once you are done, click on the Savebutton.
  3. After defining the evaluation criteria, the next step is to add the process criteria. Once the process criteria are true, the process will execute the associated actions. To define the process criteria, click on the Add Criteria node. It will open an additional window on the right-hand side of the process canvas screen, where you will have to enter the following details:
    • Criteria Name: EnterOnly when amount > $1MinCriteria Name.
    • Criteria for Executing Actions: Select the type of criteria that you want to define. You can select eitherFormula evaluates to true, or Conditions are met (a filter to define the process criteria), or No criteria-just execute the actions! In this case, select Conditions are met.
    • Set Conditions: This field lets you specify which combination of the filter conditions must be true for the process to execute the associated actions. In this case, select a Value greater than $1,000,000.
    • Conditions: In theConditionssection, select All of the conditions are met (AND). This field lets you specify which combination of the filter conditions must be true for the process to execute the associated actions.

Note

The dollar sign ($) is not required when entering the amount. What we enter as criteria can be just the raw number – that is, 10,000,000. The system will add the currency for us.

The process criteria will look as follows:

  1. Once you are done, click on the Save button.
  2. Once you are done with the process criteria node, the next step is to add an immediate action to post the opportunity details to the Chatter group. For this, we will use the Post to Chatter action, available in Process Builder. Click on Add Action, available under IMMEDIATE ACTIONS. This will open an additional window on the right-hand side of the process canvas screen, where you will have to enter the following details:
    • Action Type: Select the type of action. In this case, selectPost to Chatter.
    • Action Name: EnterPost to Sales Executive Chatter groupinAction Name.
    • Post to: This allows you to select theChatter Group,orUser,orCurrent Record, where you want to post the opportunity details. From the drop-down menu, selectChatter Group. Then, start typing the name of the Chatter group in the textbox, and selectSales Executive.
    • Message: Enter the message that you want to post. You can also use the fields above the textbox to mention a user or group, add a topic, or insert a merge field into the message.

Immediate actions will appear as shown in the following screenshot:

  1. To insert fields, click on Insert Field. To mention a user or Chatter group, use the Mention a user or group textbox. Finally, to add a topic, use the Add topic textbox. Once you are done, click on the Save button.
  1. Once you are done, the final step is to activate the process. Click on the Activatebutton, available on the button bar. Finally, the process will appear, as shown in the following screenshot:

From now on, if users create an opportunity with an amount higher than $1,000,000, the process will auto-post a textpost to the Chatter group Sales Executive, which will look as follows:

You can also achieve this through a combination of Flow and Process Builder. If you use Process Builder, you can only post a textpost, whereas if you use Flow, you can post a linkpost, textpost, and so on. It will also allow you to set CreatedById. For this, use the Record Create element and the FeedItem object.

Note

You can achieve the preceding requirement using the Post to Chatter static action or the FeedItem object, available in Flow and Process Builder. To learn more about this, refer to https://rakeshistom.wordpress.com/2014/06/14/post-opportunity-details-to-a-chatter-group/.

If you have embedded the Flow in a Visualforce page, you will need to use the Inline Visualforce page on the opportunity object in order to achieve it.

Hands on 5 – sending an email to the opportunity owner

Process Builder also allows you to send emails to users; for example, it allows you to send an email alert to the account owner as soon as an opportunity has successfully closed. 

Let's look at a business scenario. Suppose that Helina Jolly is working as a system administrator at Universal Containers. She has created a process (Post Opportunity Information to Chatter Group) to post opportunity details to a Chatter group if the amount is greater than $1,000,000. She receives another requirement, to send an email to the opportunity's account owner five days after its creation.

Follow these instructions to achieve this by using Process Builder:

  1. Process Builder doesn't allow you to create a new email alert,but it allows you to use an existing email alert that you created in the past, for the same object upon which you created a process. First of all, create an email template, Account owner notification, by navigating toSetup (gear icon) | Setup | ADMINISTRATION | Email | Email Templates, as shown in the following screenshot:
  1. The second step is to create an email alert on the Opportunity object by navigating toSetup (gear icon) | Setup | PLATFORM TOOLS | Process Automation | Process Builder | Workflow Actions | Email Alerts. Click on theNew Email Alertbutton, and save it with the name Email to Opportunity Owner. It should look as follows:
  1. To add this email alert to the existing process, navigate toSetup (gear icon) | Setup | PLATFORM TOOLS | Process Automation | Process Builder. Open thePost Opportunity Information to Chatter Group process that you created to post the opportunity details to the Chatter group. Save it as a New Version,because you can't modify an activated process.
  2. Now, we have to modify the process entry criteria, to make sure that the process will fire only when a new opportunity is related to an account record. To do that, add an entry criterion in your process, as shown in the following screenshot:
  1. To add the scheduledtime, click onSet Schedule,available underSCHEDULED ACTIONS, and Set Time for Action to Executeto five days after the opportunity's created date, as shown in the following screenshot:
  1. Once you are done, click on theSavebutton.
  1. The next step is to add a scheduled action to send an email. For this, we will use the Send an Emailaction, available in Process Builder. To add schedule actions, click onAdd Action,available underSCHEDULED ACTIONS. This will open an additional window on the right-hand side of the process canvas screen, where you will have to enter the following details:
    • Action Type: Select the type of action. In this case, selectEmail Alerts.
    • Action Name: EnterEmail to Account Owner.
    • Email Alert: Select the existing email alert. In this case, select the email alert, Email to Account Owner,which you created in step 2.

Scheduled actions will appear, as shown in the following screenshot:

  1. Once you are done, click on theSavebutton.
  1. Once you are done with the process creation, don't forget to activate the process by clicking on the Activatebutton. Finally, the process will appear, as shown in the following screenshot:

Now, this process will perform both of the jobs: posting the opportunity details to a Chatter group, and sending an email to the opportunity's account owner five days after record creation. The email will look as follows:

Note

Flow also allows you to send emails. You have to use the Send Email static action, available inside of Flow. To learn more about this, go to https://rakeshistom.wordpress.com/2014/09/08/reminder-email-to-upload-chatter-profile-photo/.

If you have embedded the Flow in a Visualforce page, you will need to use an Inline Visualforce page on the opportunity object to fulfill the preceding business use case.

Hands on 6 – checking time-dependent actions from Process Builder

To monitor a time-dependent action queue in Process Builder, follow these instructions:

  1. Navigate toSetup (gear icon) | Setup | PLATFORM TOOLS | Process Automation | Flows.
  2. Go to the Paused and Waiting Interviewssection; from there, you can check out the time-dependent action queue in Process Builder, as shown in the following screenshot:
  1. To remove a record from the time-based queue, use theDellink, as shown in the preceding screenshot.

This is because Process Builder uses a Flow Wait element to create a time-dependent action.

Hands on 7 – submitting a record to an Approval Process

Process Builder also allows you to auto-submit a record to an Approval Process. Currently, the user has to manually submit a record for the Approval Process. You can achieve this type of requirement through the following methods:

  • Using Process Builder.
  • Using a combination of Flow (submit for the approval-static action) and Process Builder.
  • Using a combination of Flow and the Inline Visualforce page on the object's detail page.

Let's look at a business scenario. Suppose that Helina Jolly is working as a system administrator at Universal Containers. She has created a process (Post Opportunity Information to Chatter Group) to post opportunity details to a Chatter group, if the amount is greater than $1,000,000, and to send an email to the opportunity's owner. She receives another requirement: to auto-submit new opportunity records to the Approval Process if the amount is greater than $1,000,000. She has already created a one-step Approval Process for this. It will send an approval request to the CEO.

Follow these instructions to achieve this using Process Builder:

  1. If you haven't created an Approval Process yet, create an Approval Process on the opportunity object, set the entry criteria opportunity amount to greater than 1,000,000, and save it with the name, Opportunity amount greater than 1M. Add one step to it, and send the Approval Request to the CEO role. Make sure that you have activated the Approval Process:

Note

If you want to learn how to create an Approval Process, refer to https://help.salesforce.com/HTViewHelpDoc?id=approvals_creating_approval_processes.htm&language=en_US.

The process (Process Builder) will fail at runtime if it allows the initial submitter to manually select the next approver.

  1. To auto-submit records to an Approval Process, you have to use Process Builder. Navigate toSetup (gear icon) | Setup | PLATFORM TOOLS | Process Automation | Process Builder. Open thePost Opportunity Information to Chatter Group process that you created to post the opportunity details to the Chatter group. Save it as a New Version,because you can't modify an activated process.
  2. The next step is to add an immediate action to auto-submit a record to the Approval Process. For this, we will use the Submit for Approvalaction, available in Process Builder. Click onAdd Action,available underIMMEDIATE ACTIONS. This will open an additional window on the right-hand side of the process canvas screen, where you will have to enter the following details:
    • Action Type: Select the type of action. In this case, selectSubmit for Approval.
    • Action Name: EnterAuto submit record into approvalinAction Name.
    • Object: This will automatically populate from the object upon which you have created the process.
    • Approval Process: You can selectDefault approval process, or, if the object contains more than one Approval Process, you can use theSpecific approval processoption from the drop-down menu. SelectDefault approval process.
    • Submitter: This allows you to choose a user to auto-submit a record to the Approval Process, and it receives all related notifications. In this case, selectCurrent User.
    • Submission Comments: Optionally, you can enter submission comments. They will appear in the approval history for the specified record. EnterAuto submit, in this case.

The immediate actions will look as follows:

  1. Once you are done, click on theSavebutton.
  1. Once you are done with the process creation, don't forget to activate the process by clicking on the Activatebutton. Finally, the process will appear, as shown in the following screenshot:

Note

You can achieve the preceding requirement by using the Submit for Approval static action, available in Flow and Process Builder. To learn more about this, go to https://rakeshistom.wordpress.com/2014/06/27/auto-submit-record-into-approval-process-with-flow/.

It is not possible to submit any related records to the Approval Process using Process Builder.

Hands on 8 – calling a Flow from Process Builder

Process Builder allows you to launch a Flow. Process Builder is another way to auto-launch a Flow. For example, there is a Flow that allows for the removal of followers from closed opportunity records. If you want this Flow to automatically execute whenever the opportunity status gets closed, you should use Process Builder. 

Some Flows don't require any user interaction to start; for example, a Flow of the type Autolaunched Flow. An Autolaunched Flow can be launched without user interaction; from Process Builder or the Apex interview.start method, for example.

Let's look at a business scenario. Suppose that Sara Bareilles, who is working as a system administrator at Universal Containers, has created a Flow to create a new opportunity using the Record Create element, as shown in the following screenshot:

Currently, she is using a custom button on the Account Page layout to call the Flow. She wants to use Process Builder to automatically fire the Flow whenever an account gets created. The VarD90DaysFromToday object is a date variable, and the VarTAccountId and VarTAccountName variables used in the preceding example are nothing but text variables. We will use Process Builder to pass the values in these variables.

Follow these instructions to call a Flow from the process:

  1. Create a Flow, similar to what is shown in the preceding screenshot; save it with the nameCreate an Opportunity. The Type should be Autolaunched Flow. Click on the Close button to close the canvas. Don't forget to activate the Flow:
  1. To create a process, navigate to Setup (gear icon) | Setup | PLATFORM TOOLS | Process Automation | Process Builder, click on the New Button, and enter the following details:
    • Name: Enter Auto create an Opportunity in Name.
    • API Name: This will be auto-populated, based on the Name field.
    • Description: Write some meaningful text, so that other developers or administrators can easily understand why this process was created.
  2. Once you are done, click on the Save button. It will redirect you to the process canvas, which will allow you to create the process.
  3. After defining the process properties, the next task is to select the object upon which you want to create a process and define the evaluation criteria. For this, click on the Add Object node. This will open an additional window on the right-hand side of the process canvas screen, where you will have to enter the following details:
    • Object: Start typing the name, and then select theAccountobject.
    • Start the process: For Start the process, select only when a record is created. This means that the process will fire only at the time of record creation.
    • Recursion:Allow process to evaluate a record multiple times in a single transaction?: Select this checkbox only when you want the process to evaluate the same record up to five times in a single transaction. In this case, leave the box unchecked.
  1. Once you are done, click on the Save button.
  2. After defining the evaluation criteria, the next step is to add the process criteria. To define the process criteria, click on the Add Criteria node. This will open an additional window on the right-hand side of the process canvas screen, where you will have to enter the following details:
    • Criteria Name: EnterAlwaysas the criteria name.
    • Criteria for Executing Actions: Select the type of criteria that you want to define. You can select eitherFormula evaluates to true, or Conditions are met (a filter to define the process criteria), or No criteria-just execute the actions! In this case, selectNo criteria-just execute the actions! This means that the process will fire in every condition.
  3. Click on the Savebutton.
  4. Once you are done with the process criteria node, the next step is to add an immediate action to launch a Flow. For this, we will use the Flows action, available in Process Builder. Click on Add Action, available under IMMEDIATE ACTIONS. This will open an additional window on the right-hand side of the process canvas screen, where you will have to enter the following details:
    • Action Type: Select the type of action. In this case, selectFlows.
    • Action Name: Enter Auto create new Opportunity in Action Name.
    • Flow: Select the Flow that you want to execute. In this case, select the Create an Opportunity Flow.
    • Set Flow Variables: Use this to pass the value in your Flow variables. For the current use case, map the VarD90DaysFromToday variable with the formula TODAY() + 90, the VarTAccountId variable with [Account].Id, and the VarTAccountName variable with [Account].Name.

The immediate actions will look as follows:

  1. To assign the value to multiple variables, click on the Add Rowlink. Once you are done, click on theSavebutton.
  2. The final step is to activate the process. Click on the Activatebutton, available on the button bar. Finally, the process will appear, as shown in the following screenshot:

From now on, if an account gets created, Flow will automatically be executed by Process Builder, and a new opportunity will be created.

 

A few points to remember


The following are some noteworthy points regarding Process Builder:

  1. A process's API name must be less than, or equal to, 77 characters, and it's always associated with a single object.
  2. Using Process Builder, you can't delete records. If you want to do that, you have to use Flow with Process Builder.
  3. To set the Text data field to blank, you can use {!$GlobalConstant.EmptyString}.
  1. By default, the process owner will receive an email from Salesforce. If the process fails at runtime, or if any fault occurs, the error or warning messages might refer to a Flow instead of a process. If you want to notify other users and your IT department, use the Apex Exception Email, under the Salesforce setup. 
  2. The process follows all of the governor limits that apply to Apex.
  3. You can have a maximum of 50 active rules and processes on any object. Rules include Workflow Rules, Escalation Rules, Assignment Rules, and Auto-Assignment Rules.
  4. Process actions are executed in the same order in which they appear in the Process Builder.
  5. You can't delete an active process; first, you have to deactivate it. Once you have deactivated a process, you can immediately delete it.
  6. If a custom field is referenced in a process/Flow, you can't delete that field.
  7. Before you change a custom field’s type or name, make sure that it isn’t referenced in a process that would be invalidated by the change.
  8. An immediate action on a record update obeys validation rules.
  9. A scheduled action on a record update skips validation rules.
  10. If any of the actions fail, the entire transaction fails and an error message is displayed.
  11. File type custom fields aren’t supported in Process Builder.
  12. External objects and deprecated custom objects aren’t supported in Process Builder.
  13. If a single action group includes multiple Update Records actions that apply different values to the same field, then the last action’s value is used.
  14. The total number of process criteria nodes that are evaluated and actions that are executed at runtime is 2,000.
 

Exercises


  1. Create a one-step Approval Process for an account, to get an approval from the CEO once an account becomes active. Use Process Builder to automatically submit an account for approval, once it gets activated.
  2. Automatically update the lead rating to Warm whenever the lead status gets updated to Working—Contacted.
  1. Develop an application using Flow and Process Builder. It will automatically remove all of the followers from an opportunity, except for the opportunity owner, once its stage is updated to Closed-Won or Closed-Lost.
  2. Automatically create a child case whenever a case is created with a High priority. Use the following information to create the child case:
    • Status: New
    • Priority: Medium
    • Case Origin: Phone
    • Associate it with a high priority case
  3. Create a one-step Approval Process for an account, to get an approval from the CEO once an account becomes active. Use Process Builder to automatically submit an account for approval once it gets activated.
  4. Develop an application, using Flow and Process Builder, that will automatically add a new user that has the role of Sales Executive to the Sales Executive Chatter group.

Note

If the Sales Executive Chatter group does not exist in your Salesforce organization, create a new one.

  1. Once the account has been created, auto-post the account details to a Chatter group (Sales Executive).
  2. Once the opportunity has successfully closed, auto-post a linkpost on a Chatter group (Sales Executive). The output should look similar to the following screenshot:
  1. Auto-create a child case whenever the case's Type field changes to Mechanical, and assign it to the Mechanical Engineers queue.

Note

If the Mechanical Engineers queue does not exist in your Salesforce organization, create a new one.

  1. Whenever a case is created, automatically add the user Helina Jolly to the case team members.

Note

Create a new user in your organization, named Helina Jolly.

  1. First, set the OWD for Lead to Private. Now, develop an application, using Flow and Process Builder, that will automatically share new lead records with the user Helina Jolly, and grant her read/write access.
  2. Once an account becomes inactive, send an email notification to all opportunity owners related to that account. Also, update any related open opportunities' statuses to Closed Lost.

Note

Use theActivefield to decide the account status.

  1. Once an opportunity has successfully closed, auto-create a new opportunity by copying the data from the closed opportunity. Set the opportunity closed date as the new opportunity's created date, plus 100 days.

Note

Copy only the field that is required to create an opportunity.

  1. Create a process that will automatically add new users that have the profile APAC Support Agent to a queue (High Priority Accounts).

Note

If the High Priority Accounts queue and the APAC Support Agent profile do not exist in your Salesforce organization, create new ones.

 

Summary


In this chapter, we went over the various actions available in Process Builder. We looked at a way to auto-create and update a record. We also covered various ways to call a Flow from Process Builder. Then, we moved on to discussing ways to auto-submit a record to the Approval Process and send emails to users. We also discussed how to call Apex from Process Builder. Finally, we discussed the key points of Process Builder. In the next chapter, we will discuss concepts related to deploying and distributing Flows and Processes. We will also look at concepts such as how to debug your Flow and send a process error email to users other the process owner

About the Author

  • Rakesh Gupta

    Rakesh Gupta is best known as an automation champion in the Salesforce ecosystem. He has written over 150 articles on Visual Workflow and Process Builder to show how someone can use Visual Workflow and Process Builder to minimize code usage. He is one of the Visual Workflow and Process Builder experts in the industry. He has trained more than 700 individual professionals around the globe and conducted corporate training. Currently, Rakesh is working as a Salesforce solution architect consultant.

    Browse publications by this author

Recommended For You

Salesforce Platform Developer I Certification Guide

Build and deploy scalable applications on the Salesforce Lightning Platform using the latest features of Spring '19

By Jan Vandevelde and 1 more
Salesforce Advanced Administrator Certification Guide

Master advanced Salesforce Administration concepts with expert tips, techniques, and mock tests

By Enrico Murru
Salesforce CRM - The Definitive Admin Handbook - Fifth Edition

A definitive guide covering all the core concepts necessary to pass the Salesforce Administrator Certification exam

By Paul Goodey
Salesforce Lightning Cookbook

Over 25 recipes to help you design and test informative applications on the Salesforce Lightning platform

By Syed Chand Shah