Process builders are used to do automation in salesforce with point and click admin tools. They are an alternative to Workflow Rules.
Process builders can be used to do the following actions :
- Create and update records.
- Send an Email alert.
- Submit a record for approval.
- Invoke a process from another process.
- Launch a flow.
- Call apex methods.
- Post to chatter
Difference between Process Builder and Workflows
Process Builders provide the functionality which is not provided by Workflow Rules:
- Submitting a record for an approval process.
- Call an apex method.
- Post to chatter.
- Launch a flow.
- Create a new record.
Whereas, workflow rules support the ‘Outbound Message’ action which is not supported by Process Builders.
Just like the workflow rules, Process Builders also support time based actions, which execute after a certain time period.
Lastly, Process Builders can update parent records linked via a lookup as well. Whereas in Workflow Rules, we can only update the parent record if its linked via a master-detail relationship.
Creating a Process Builder
You can create process builders in classic and lightning by going to Setup -> Search Process Builders.
In Classic :
In Lightning :
Click on the Process Builder item to open all the Process Builders in your org.
Click on the ‘New’ button on top right to create a new Process Builder. Give it a name as per your convention.
In the ‘The process starts when’ option, choose :
A record changes : If we want the process builder to work when a record is inserted/updated.
A platform event is received : If we want to fire a process builder when a platform event is received.
It’s invoked by another process : If this process builder is only called from any other process builder.
Setting up the Criteria and Choosing Actions
After you choose one of the options, we will see this screen :
We can select the object,set the criteria and choose the actions to perform pretty easily.
For example, let’s say that we want to run the process builder on the Account object, then we can click on the ‘Add Object’ option and choose the object as follows :
Here, if we want to run the process builder only on insertion of the Account record we can choose ‘only when a record is created’ option.
If we want it to run on both creation and updation of the record, then we need to choose the ‘when a record is created or edited’ option.
Once, you have setup the Object, then we can move on to setting up the criteria for the process builder:
Criteria selection is possible via creating a logical statement with the ‘Set Conditions’ section. If you wanna use a custom formula with AND and OR operators we can use the ‘Formula Evaluates to True’ option.
And if we don’t want to set any criteria, we can use the ‘No Criteria-just execute the Actions!’ option.
After the criteria is set up we can define the Actions to perform in our process builder.
Lastly, don’t forget to Activate your Process Builder after creating it!
Process Builder Example
Let’s say we want to set up a process builder to update the name on an account record to ‘SalesforceDrillers’ as soon as any new account is inserted.
So let’s set up a process builder to do so! Go to ‘Process Builder’ from the Setup and create a new Process Builder called ‘Populate Account Name’. Choose the ‘A record changes’ option for the ‘The process starts when’ option. And click on ‘Save’.
We first need to set up the Process Builder to work on the Account object and so that it only works when the Account record is created.
Click on the ‘Add Object’ link and choose the ‘Account’ object. And leave the ‘Start the Process’ option as ‘only when a record is created’.
Click on the ‘Save’ button to set up the Object.
Then click on the ‘Add Criteria’ button to set up the process builder to work everytime a new Account is created. So we can choose the ‘No criteria—just execute the actions!’ options for the criteria.
Click on ‘Save’ to save the criteria.
Then, we need to add the action to update the name of the Account record. Click on the ‘Add Action’ link and choose ‘Update Records’ in the Action Type.
Then, we need to choose the record to be updated. Click on the ‘Record Type’ option and choose ‘Select the Account record that started your process’ since we want to update the same Account’s Name field.
Click ‘Choose’ to finalize the object.
Click on Save and then finally click on the Activate button on the top right to activate your process builder.
Now, create a new Account record in your org. Enter the Account Name as ‘Test’ and click Save.
Once we save the record, the Account Name is updated to ‘SalesforceDrillers’.