Adding actions to approvals
The approval process flow can be seen from the Approval History related list, but it would be cool to have a way to make modifications to the record when approval stages are passed.
In our scenario, we want to update a custom opportunity field named Approval Status, a simple picklist defined as follows:
- Name: Approval Status
- Type: Picklist
- Values: Pending (default), Submitted, Approved, Rejected
- Restricted values: Yes
- Field-Level Security: All profiles except System Administrator have read-only access
This picklist could be used to avoid closing deals that haven’t been approved yet (for example, by creating a validation rule on the opportunity object that uses the Approval Status and the Closed fields) or even to enable a new approval run if the amount field is updated (using a workflow rule or a process builder): we can even add more conditions to the approval entry criteria to avoid submitting a record if it has already been approved or rejected.
As we saw in the previous chapter, there are several automated actions available. Approval processes can use the following actions:
- Task: Assigns a task to the approver to set a schedule for the approval or a task to the submitter after a rejection to discuss the reasons behind the rejection with their manager.
- Email Alert: Sends an email when a response is done.
- Field Update: Updates a field on the opportunity.
- Outbound message: Notifies an external system of an approved billing request.
- Record lock: An approval-specific action used to lock/unlock the record during the approval flow. If the record is locked, it cannot be updated by anyone. An exception in this regard is made for the system administrator or any user with the Modify All Data permission or Modify All object-level permission.
We won’t discuss how automation actions work in this chapter; refer to the previous chapter for more details.
Where can actions be added on the approval? As we have already seen in the previous section, the approval process detail page shows a diverse related list:
- Initial Submission Actions: Actions are executed when the user submits the approval. A default lock action is preconfigured when the approval is created.
- Final Approval Actions: Actions are executed when the record is successfully approved. A default lock action is already there (from the submitter’s point of view, the record is approved and should not be changed).
- Final Rejection: Actions are executed when the record is rejected. A default unlock action is already preconfigured when the approval is created.
- Recall: A submitter could recall the approval request. Actions are executed in this eventuality (for example, to restore the approval status to the not-yet-submitted value).
- Approval Step Approval/Rejection: Actions can be added on a specific step’s approval/rejection events. Default lock/unlock actions are already configured. To show step-specific actions, click on the Show Actions link next to a step definition, as shown in the following screenshot:
Approval step actions configuration
We won’t add any step-related actions but only Initial Submission, Final Approval, and Final Rejection actions, according to our scenario.
Let’s configure three different Field Update actions on the Approval Status picklist that set the following values:
- Action: Set Submitted Approval
- Position: Initial Submission Actions
- Approval Status value: Submitted
- Action: Set Approved
- Position: Final Approval Actions
- Approval Status Value: Approved
- Action: Set Rejected
- Position: Final Rejection Actions
- Approval Status Value: Rejected
That brings us to the following configuration:
Approval actions configured
Note that the Record Lock action in the Final Approval Actions section has been changed to Unlock the record for editing, as we want the submitter to be able to update the record if they want.
The approval process is ready. We can activate the approval process by clicking the Activate button on the details page header.
Once an approval process has been activated, no more steps can be added or removed. Deactivate it and clone it to create a new version with more or fewer steps. Bear in mind that some attributes cannot be modified, such as step order.