Use Flow to Approve, Reject and Cancel Approval Processes

You can create a Resolve Approval Request action that allows your flows to approve, reject or remove Salesforce approval processes. The action looks like this:

Input Attributes

actionSupported values: Approve, Reject, and Removed (See this for more info).
approvalRequestIdThis can be extracted from email notifications. See this.
commentsText provided here will be saved in Approval Activity History
nextApproverIds (See this for more info).


This action is used to work around a bug in Approval Processes.


Instead of installing a package, you’ll need to copy this apex code and add it to your org as a new Apex class ( It’s not currently possible to package actions that use Approval Process apis.) You can create the class using Developer Console or Setup -> Custom Code -> Apex Classes. After creating the action, you can create a flow like this:

In the example flow above, the first action is the Find Text action . It’s used in this specific example to extract the id of the approval process from an email notification. In other use cases, you’ll be able to get the approval process id in other ways.

Creating a Test Class

Andy Haas has added a nice test class to this project called ResolveApprovalRequestsTest.cls. As he explains:

This test class will help pass the Resolve Approval Requests to production. Unfortunately, a lot of hardcoding had to be done as Process Instances, and Process Definitions can not have a DML insert function. So you’ll need to inspect this test class and replace various strings to match them up with your org.

When using this test class, you will need to create the following:

  • An Account with the name “Acme (Sample).”
  • An Approval Process on the Account object with a Developer Name “Test_Process_Definition.”
  • Activate the Approval Process
  • Submit for Approval the Acme (Sample) account. Leave it as pending, as that is what the code looks for.

If you want, you could make these changes within the test class to fit your orgs’ test records, but this will need to be done for this class to run. You then will get a 93% code coverage.