Do you want to create a record for any object from a workflow? Do you want to call your Apex class from a workflow? Do you want to automatically submit a record for approval without pressing “Submit for Approval” button or without writing a trigger? The answer is Process Builder.
Salesforce introduced a powerful feature to meet all above requirements, and it is called Process Builder.
Now, let’s discuss what the process builder is and how to use it.
What is Process Builder?
Process builder is used to automate more complex business process just by a few point and click actions. It provides a user – friendly representation for building a process in Salesforce.
Fig 1. Process Builder UI
1. Button Bar
Use the button bar to collapse and expand actions, clone the process and activate/deactive the process.
Canvas is a main workplace for the process
3. Add Objects
The records that the process should evaluate
4. Criteria nodes
Entry criteria node includes conditions that are used to evaluate the records.
If the criteria met for the record that starts the process, the actions start immediately or at a scheduled time.
Process Builder is the next version of a workflow tool. You can implement all the workflow actions except outbound message, using Process Builder. Also, Process Builder provides some additional features to accomplish complex flows. Process builder features:
1. Create a Record
- Creates a record by manually entering values or by using the values of related records.
2. Update any related record
- Updates one or more records—that are related to the record that started the process—by manually entering values or by using the values from related records.
3. Quick Actions
- Create a record, update a record, or log a call by using an object-specific or global action that you or another administrator created for your organization
4. Launch a Flow
- Launches a flow from your process to automate complex business processes—creates flows to perform logic and enables events trigger the flows via processes—without writing code.
5. Send an Email
- Easily send an email from a process by using an email alert. Email alerts are configured outside of the Process Builder and contain the standard text, list of recipients, and template for the email.
6. Post to Chatter
- Post to the feed of a user, a Chatter group, or the record that started the process.
7. Submit for Approval
- Submit the record that started the process for approval.
- Now, you can call an Apex from process builder for a particular scenario without going for trigger and Visualforce.
- And also that Apex should have @invokeablemethod.
Let’s discuss above features now:
If an Opportunity is closed Won, Create a Contract Record and Submit this record for manager review. If theOpportunity is Closed Lost, Send an Email notification to VP.
In this scenario, the following actions will take place:
- Create a New Record
- Submit for Approval
- Email Alert.
Please follow the below steps to accomplish the scenario.
- Click Setup -> Create -> Workflow & Approvals -> Process Builder
- Click [New] Button.
- Fill in the Name and Description fields and Submit [Save] button.
- Click [+ Add Objects] in the flow chart and Select Opportunity Object.
- Click the [Save] button.
- Click [+ Add Criteria] in the flow chart and Enter the evaluation criteria.
- Click the [Save] button.
- Now, you can define actions that are executed when criteria are met. You can add upto 10 immeidate actions and 10 scheduled actions.
- Click [+ Add Action] in Immediation Actions.
- Select Action Type as “Create a Record” and Select Object as “Contract” from the drop down and set the values for Object variables. Then, Click [Save].
- Click [+ Add Action] and
- Select Action Type as “Submit for Approval from dropdown.
- Enter the value for Action Name
- Object is “Opportunity” by default because the process is created for the Opportunity object.
- Select Approval Process as “Default Apporval Process or Specific Apporval Process”. If you select the “Specific Apporval Process”, you should enter your exiting opportunity approval process name in the next text box.
- If you want skip the entry criteria for approval process , you can check the checkbox or you can leave it as unchecked.
- Select Submitter from the dropdown. Submitter may be “Current User (or) User field from the record (or) Other User”. If you select “Other User”, you have to enter username in the next textbox.
- Submission Comments is optional.
- Click the [Save] button.
So far, The process is completed for Opportunity Closed Won. Suppose, if the Opportunity’s Stage is Closed Lost, you need to Add criteria in the “Else” part and create Email Notification Action.
Now, the Flow is:
Likewise, based on your business requirements, you can create your flow and action using the Process builder. You can select one of these actions for the “Action Type” dropdown.
Process Builder Limitations.
- Process Builder and process are supported only in English.
- If you create processes for existing triggers and workflows, you should inactivate or delete those workflows and triggers first. Otherwise, it will show unexpected exception when the process runs.
- Actions are executed in the order in which they were specified in the process builder, and you can’t change it.
- If any one action fails, entire process will fail and an error will be displayed.
- If an object is deleted, all the processes associated with that object also deleted.
- Process builder can’t be included in ChangeSet.
For more information please refer this link.
Process builder is used to to automate your organization’s repetitive work or business processes, and it reduces number of workflows and triggers in your Salesforce organization.