Ora

How to Debug Approval Process in Salesforce?

Published in Salesforce Debugging 6 mins read

Debugging an approval process in Salesforce primarily involves using debug logs to trace the system's execution and systematically checking the configuration of your approval process components. This approach helps pinpoint where a record might be failing to enter, progressing incorrectly, or failing to execute its associated actions.

Leveraging Debug Logs for Approval Processes

Debug logs are the most powerful tool for understanding the behind-the-scenes operations in Salesforce, including how an approval process interacts with data and other automation. They capture detailed information about database operations, system processes, and errors that occur within a transaction.

Setting Up Debug Logs for Approval Debugging

To effectively use debug logs for an approval process, you need to monitor the specific user who triggers the process.

  1. Navigate to Setup: From Salesforce Setup, search for and select Debug Logs.
  2. Add a Monitored User: Click New in the "Monitored Users" section.
  3. Select the User: Choose the specific user account that will initiate the approval process (e.g., the user creating or editing the record that should trigger the approval).
  4. Set Debug Levels: For comprehensive troubleshooting, set the debug level to FINEST for all categories (Database, Workflow, Validation, Callout, Apex Code, Apex Profiling, Visualforce, System). While this can generate very large logs, it ensures you capture all relevant details.
  5. Set Start and Expiration Times: Define the period during which the log should be active. Ensure it covers the time you plan to test.
  6. Initiate the Approval: Log in as the monitored user and perform the action that should trigger the approval process (e.g., create a new record, update an existing one).
  7. Review the Debug Log: Go back to the Debug Logs in Setup. A new log should appear for the monitored user. Click View to open and analyze it.

What to Look For in the Logs:
When reviewing the log, pay close attention to entries related to "Workflow," "Approval," "Validation," and "DML" (Data Manipulation Language). These sections will show:

  • Whether the approval process entry criteria were evaluated and met.
  • Which steps were considered or executed.
  • Any errors or validation failures that occurred.
  • The execution of associated actions like field updates or email alerts.

Common Areas to Check When Debugging Approval Processes

Beyond debug logs, many approval process issues stem from misconfigurations within the process itself. Systematically review these areas:

1. Entry Criteria Verification

The most common reason a record fails to enter an approval process is unmet entry criteria.

  • Accuracy of Criteria: Double-check that all criteria are correctly defined (e.g., Status = 'Pending Approval', Amount > 10000).
  • Field Values: Ensure the record's field values match the criteria at the time of submission.
  • Logic Operator: Verify if the ALL (AND), ANY (OR), or custom logic ((1 AND 2) OR 3) is correctly applied.
  • Formula Fields: If using formula fields in criteria, ensure they evaluate to the expected result.

2. Approval Steps Configuration

Issues often arise within individual steps of the approval process.

  • Step Criteria: Each approval step can have its own criteria. Ensure these are met for the record to progress to that specific step.
  • Assigned Approver:
    • Is the correct user, queue, or related user field (e.g., Manager, Owner) designated as the approver?
    • Does the assigned approver actually exist and have the necessary permissions?
    • Is delegated approval configured correctly if applicable?
  • Rejection Behavior: What happens when an approver rejects a request? Ensure the "Go to previous step," "Go to first step," or "Final Rejection" options are configured as intended.
  • Approval Actions: Verify that any field updates, email alerts, or tasks associated with a step's approval or rejection are correctly configured and pointing to valid entities.

3. Initial Submission & Final Approval/Rejection Actions

The actions performed at the beginning and end of the process are critical.

  • Initial Submission Actions: Check if field locks, email notifications, or field updates are firing as expected when a record is first submitted.
  • Final Approval Actions: Ensure all intended actions (e.g., changing status to "Approved," sending a final email, unlocking the record) execute upon final approval.
  • Final Rejection Actions: Similarly, verify actions upon final rejection (e.g., status to "Rejected," email notification).

4. Field Updates and Locks

Confirm that field values are being updated correctly and record locking/unlocking behavior matches expectations.

Issue Common Checks
Record not entering approval process - Entry Criteria: Are they met by the record?
- Field Values: Are the fields on the record accurate?
Wrong approver assigned - Approval Step Criteria: Are the conditions for the step met?
- Assigned Approver: Is the correct user/queue selected, or is the lookup field (e.g., Manager) populated?
Actions (email, field update) not firing - Initial Submission/Step/Final Actions: Are the actions enabled and correctly configured for the specific stage?
- Email Deliverability: Is Salesforce email properly configured?
Record stuck / incorrect status - Step Criteria: Are subsequent step criteria preventing progress?
- Rejection Behavior: Is the path on rejection clear?
- Other Automation: Are Flows, Process Builders, or Workflow Rules interfering?
Approver cannot approve - Permissions: Does the approver have necessary object/field permissions?
- Delegated Approvers: Is the delegate correctly set up and active?
- Email Address: Is the approver's email address valid?
Record remains locked after approval - Final Approval/Rejection Actions: Is there an action to unlock the record?

Other Considerations & Best Practices

  • Order of Execution: Be aware that approval processes run within Salesforce's order of execution. Other automation like Flows, Process Builders, or Workflow Rules can run before or after the approval process logic, potentially causing conflicts or unexpected behavior. Debug logs will show this sequence.
  • Email Deliverability: If email alerts aren't being sent, verify your organization's Email Deliverability settings in Setup (search for "Deliverability").
  • User Permissions: Ensure both the submitting user and the designated approvers have the necessary object and field-level permissions to perform their respective actions.
  • Test in Sandbox: Always develop and test approval processes thoroughly in a sandbox environment before deploying to production.
  • Simplified Design: While powerful, complex approval processes with many steps, criteria, and actions can be challenging to debug. Consider breaking them down or simplifying where possible.
  • Apex Triggers: If your approval process interacts with Apex triggers, review their code and associated debug logs for errors or unexpected behavior.

By combining the detailed insight from debug logs with a systematic review of your approval process configuration, you can efficiently diagnose and resolve issues.