Sub topic 8
Field updates, email alerts, tasks, and outbound messages
This chapter assumes you know the parts of an approval process (entry criteria, steps, approvers) and the five action points: initial submission, step approval, step rejection, final approval, final rejection, and recall. It also assumes you have used workflow rules or can read a workflow action list. Here you will learn what each action type does, where it fits in an approval, and what commonly goes wrong.
The working model
An approval process runs automated actions at fixed points in its life. Salesforce offers four action types for these points. They are the same types used by workflow rules.
- Field update changes a field value.
- Email alert sends an email built from an email template.
- Task creates an activity assigned to someone.
- Outbound message sends a SOAP message to an external endpoint.
You attach actions to these action points:
- Initial submission actions run when a record enters the process.
- Step approval actions and step rejection actions run when a specific step finishes.
- Final approval actions run when the last step is approved.
- Final rejection actions run when the record is finally rejected.
- Recall actions run when a submitter or admin withdraws the request.
Actions are reusable. You create a field update, email alert, task, or outbound message once and then add it to many action points or processes. Editing the shared action changes it everywhere it is used. Keep this in mind before you edit an action that another process also uses.
Choosing the right action type
| Action type | What it does | Typical approval use |
|---|---|---|
| Field update | Sets a field to a value, blank, formula result, or new owner | Set Status to Submitted, Approved, or Rejected |
| Email alert | Sends a templated email to chosen recipients | Tell the submitter the outcome |
| Task | Creates a task on the record | Ask someone to follow up after approval |
| Outbound message | Sends field values to an external system | Notify an ERP that a discount is approved |
Field updates
Field updates are the most common approval action. Their main job is to keep a status field in sync with the approval state. Locking tells users a record is in approval, but a status field is what reports, list views, and validation rules can read.
A common pattern for an opportunity discount approval is:
- Initial submission: set
Approval_Status__ctoSubmitted. - Final approval: set
Approval_Status__ctoApproved. - Final rejection: set
Approval_Status__ctoRejected. - Recall: set
Approval_Status__ctoRecalled.
A field update can:
- Set a specific value, such as a picklist value or checkbox state.
- Clear the field.
- Calculate a value with a formula.
- Change the record owner, when you configure an owner field update.
Some details to remember:
- Field updates run with system privileges. They can change a field the approver could not edit, and they can change a record that is locked.
- A field update can update a parent record in some relationships, for example a child on a master-detail relationship updating its master. Check which fields are available when you create the update.
- The "Re-evaluate workflow rules after field change" option makes workflow rules run again after the update. Leave it off unless you need it. It can cause loops where one rule triggers another.
- A field update still has to satisfy the field's data type. A formula that returns text into a number field fails when it runs.
Email alerts
An approval process already sends an approval request email to approvers. That email uses the template you pick on the process. Email alerts are separate. They are for everyone else who needs to know, such as the submitter, a manager, or a mailing list.
To build an email alert you need:
- An email template. Use Lightning or classic templates with merge fields such as the record name and amount.
- Recipients. Choose from users, roles, public groups, the record owner, the creator, related users, and email fields on the record.
- Optional extras. These include additional email addresses and a from address, such as an organization-wide address.
Keep these points in mind:
- Email alerts count against a daily limit for workflow email. Large or looping approvals can reach it.
- Merge fields only show data the template can read. Test with a real record to confirm that the fields show.
- If the recipient is an email field that is blank, no message goes to that person.
- Email deliverability settings apply. If email access is set to "No access" in a sandbox, alerts are not sent. Sandboxes often have this setting after a refresh.
Tasks
A task action creates a task related to the approval record. Use it when the approval outcome needs a person to do something, such as "Send the signed contract" after final approval.
When you define a task, you set:
- Assigned To. Pick a user, a role, the record owner, or the record creator.
- Subject, Status, and Priority.
- Due date. This is a number of days after the rule trigger date or another date field.
- Notify Assignee. This sends an email notification when the task is created.
Things to check:
- Activities must be enabled for the object. If they are not, the Task option is not available.
- Pick the assignee type carefully. A task assigned to the record owner follows an owner change. A task assigned to a fixed user stays with that user.
- A task is a record, so it appears in reports and on the activity timeline. Many approvals creating tasks can fill the timeline. Create a task only when someone has work to do.
Outbound messages
An outbound message sends a SOAP message with chosen fields to an endpoint URL. It is the integration option among the four, and it is the only one that talks to another system.
To configure one, you provide:
- Endpoint URL. The address of the listener that receives the message.
- User to send as. The user whose context the message uses.
- Fields to send. Select only the fields the receiver needs.
- Send session ID. Optional. It lets the receiver call back into Salesforce, so avoid it unless the receiver needs it.
Outbound messages are queued and retried. If the endpoint does not return a positive acknowledgment (an Ack of true in the SOAP response), Salesforce keeps retrying for up to 24 hours. This has two consequences:
- Your receiver must be idempotent. It may receive the same message more than once, so use the record ID or notification ID to ignore repeats.
- A broken endpoint creates a queue of pending messages. You can view and manage them in Setup under Outbound Messages in the monitoring tools.
Common errors and how to avoid them
- Status never changes. You added the field update to the wrong action point. Check that approval, rejection, and recall each have an update.
- Record shows Approved but is still locked, or the reverse. Locking is controlled by the process setting, not by your status field. Confirm the record lock option on the process.
- Recall leaves a stale status. Teams often add submission and final approval updates but forget recall. After a recall, the status still reads
Submitted. - Shared action edited by mistake. You changed a field update used by another process. Give each process its own actions when behavior differs.
- Validation rule blocks an action. Update the rule to allow the approval states, or make the rule skip records that are being updated by the approval process.
- Duplicate integration calls. The receiver of an outbound message processed a retry as a new event. Make the receiver idempotent.
- Do not rely on action order. Actions at one action point do not run in a guaranteed order. If one action depends on another, such as an email that shows a field another action updates, test it and consider a different design.
Design guidance
Keep the number of actions small. Each action is one more thing to test and maintain. A good starting set is one status field update per action point, one email alert to the submitter on final approval and final rejection, and an outbound message or task only when another system or person needs it.
Exercise
A discount approval has final approval and final rejection actions that set Approval_Status__c. Users report that after they recall a request, the field still says Submitted. What is missing, and what should you add?
Show answer
The process has no recall action. Recall actions are a separate action point, so the final approval and final rejection updates do not run. Add a field update to the recall actions that sets Approval_Status__c to a value such as Recalled, then recall a test record to confirm the field changes.
Exercise
An outbound message from final approval reaches your ERP endpoint, but the ERP sometimes creates the same order twice. Give the likely cause and a fix.
Show answer
The endpoint is not returning a positive acknowledgment quickly, or it is returning one after a delay, so Salesforce retries the message for up to 24 hours. The ERP then handles each retry as new. Fix the receiver so it returns Ack true promptly and ignores repeats by checking the notification ID or the record ID before it creates an order.