The Lightning Process Builder helps you easily automate processes by providing a powerful and user-friendly visual representation of your business logic.
It combines the features of the workflow rules, the approvals, and Apex, allowing you to:
- Create a record
- Update any related record—not just the record or its parent
- Use a quick action to create/update a record and log a call
- Launch a flow as an immediate or a scheduled action
- Send an email
- Post to the Chatter
- Submit for approval
Wow! It seems I can use Process Builder to do everything in Salesforce, is it right? No, it isn’t. Process Builder is another powerful option you can consider, but it will not substitute Apex, workflow rules, and approvals at all. Obviously, you need to understand the pros and the limitations before making a choice.
Lightning Process Builder Pros
A simple and flexible User Interface
The UI is really user-friendly. It consists of the following parts:
- A button bar with useful actions, such as Clone and Activate the process
- The records evaluation criteria: when a record is created/edited
- One or more criteria nodes: each criterion includes the conditions to evaluate if a record should enter into the specific business logic branch
- One or more immediate or scheduled actions, executed when the associated criteria are satisfied
A simple and flexible User Interface
Instead of defining multiple workflow rules that manage the complexity of a specific business logic, you can design a single flow containing all the different cases. You can simply create criteria to trigger specific actions and then define additional criteria in case the first one is not executed.
Versioning is probably one of the most useful features. It allows the developer to recover a previous version in case of errors, instead of using an external control system. By activating a version, the old active one is automatically deactivated.
No test class
As well as workflow rules and approvals you don’t have to write test classes. It will reduce the deploying-time but be careful, automate testing can save your life. In addition, you must pay attention to the impact of the defined process builder on other Apex Classes, in order to avoid an ugly “CANNOT_EXECUTE_FLOW_TRIGGER” or similar errors.
Use Case: Update a field (address) in Account object and do it in all related contacts
In this simple use case, we are going to update child objects when the parent object is modified. In particular, we want to update Contact records whenever the Account billing address changes. Let’s see how:
Step 1 – Create a new process
Create a new process from the process builder page (search Process Builder from Setup in Lightning or Classic), and insert the following info:
- Process Name: Contact address change
- The process starts when: A record changes
Step 2 – Set the main object
In the “Add Object” box, select Account and flag the option “when a record is created or edited”
Step 3 – Add criteria
Add the process criteria in the “Add Criteria” part, specifying the following information:
- Criteria Name: Address Change
- Criteria for Executing Actions: Conditions are met
- Set the “Billing Street” as field, “is changed” as Operator and “True” as value in the Filter Conditions
- Conditions: All of the conditions are met (AND)
Step 4 – Add actions
Under the Immediate Actions box click “Add Action” and insert the following information:
- Action Type: Update Records
- Action Name: Update Contact Addresses
- In the Record Type part choose “Select a record related to the Account” and then select “Contacts” as related records
- Criteria for Updating Records: No criteria—just update the records!
- In the Set new field values for the records you update part choose “Mailing Street” as field, “Reference” as Type and “Billing Street” as Value
Step 5 – Activate it!
Activate the process and test it. Does it work? Cool, you defined your first Process Builder!
Process Builder Limitations
Limitation 1: Outbound Message
It’s not possible to send outbound messages, as you do with Workflow Rules. This limitation can be overtaken by defining an apex class and recall it by setting Action Type “Apex”.
Limitation 2: Apex Trigger vs Process Builder
Each process can be associated with a single object only. Therefore, if you need to update multiple objects when an event occurs, Apex can be the solution.
As I said at the beginning, Process Builder is a powerful tool to visually design business logic, but it can’t substitute Apex, Workflow Rule, and approvals so far. Anyway, Salesforce is investing a lot in this feature, so we will probably receive interesting surprises in the next future! Stay tuned!
Support us with a small donation:
- LTC Address: La5f6W1rPr5VHFGCrCmPJ3sSa2AiwKZJbU
- BTC Address: 1FG1j42MUze8jiW7JbgNaUMZxZeu7M1b4f
- Ripple Address: rPVMhWBsfF9iMXYj3aAzJVkPDTFNSyWdKy Tag: 562614972
- ETH Address: 0x0940958167ca9cbd6409999957a011be7907d904