Using Flow to Process Approval Requests Automatically

There’s a bug in Approval Process involving a feature that’s designed to auto-approve an approval request if a specified step entry criteria is not met. This post describes a way to work around that bug.

This feature is normally activated here:

When this feature works properly, you can see it displayed here:

In certain situations, as described here, you can follow the steps but you won’t see the ‘else Approve’. One combination is when the previous step has an Auto-Skip pathway, as shown below. The first step has ‘else Next Step’ and the second step fails to show the ‘else Approve’:


The workaround for this bug involves creating an special User account that automatically approves every approval requests it receives, and adding a step that calls that ‘autoapprover’ if the conditions warrant.

Here’s the general flow:

Preparing Your Approval Process For AutoApproval

Let’s go back to our example from above. We have a step that we want to enter if the industry is not Agricultural. If it is Agricultural we want an automatic approval: However, the bug in approval processes prevents the auto approval:

For our workaround, we need to add a step that causes immediate approval if the step gets executed. We’ll do this by adding a new step 2 called Autoapprove Agricultural Accounts that executes immediately before our malfunctioning step. Note that 1) its criteria is set up to be the exact opposite of the original step 2, and it uses ‘go to next step’:

Importantly, We also modify our original step 2 so that it also uses ‘go to next step’. If we leave it on ‘approve record’ it will actually reject the record, which may not be what we want. Basically, since ‘Approve Record’ is broken, you don’t want it in any part of your process.

Assigning the Step to a Special AutoApproval User

We assign our new Autoapprove Agricultural Account step to the newly created User called Autoapprover User:

This is just a normal User, but it has a special email address: 

We’ll touch on that in a moment. First, let’s review what we’ve done so far. After Step 1, our new Step 2 gets evaluated. If the industry is Agricultural, Step 2 will execute as normal and send an email notification to the AutoApprover User’s email account. Otherwise, the approval process will carry on to the original Step 2.

Adding an AutoApproval Capability to your Org

If our new Step 2 gets entered, we want it to cause the request to immediately be approved. To do this, our AutoApprover User uses as its email address a special Salesforce Apex Email Service Address that you’ll generate by setting up an Apex Email Service. This service provides an email address and will auto-process email received at that address. 

Normally, you give each Email Service the name of an Apex Class that you’ve coded up to handle the incoming email. But we don’t want users to need to write code, so we’re going to use a Flow extension that provides Email Services with an Apex Class that knows how to take the incoming email and pass it to a flow. 

Below, you’ll see instructions to create a flow called Auto Approve Request that is designed to be passed an email body by an Email Service. The flow then uses the Find Text action to extract the id of the Approval Process and then uses a new Resolve Approval Process action to approve the request. Here’s what Resolve Approval Process looks like: 

When this action executes, the request will be approved.

Installing the AutoApprover Extensions

Step 1: First, install the EmailToFlow Extension.

This enables any Salesforce inbound Email Service you create to pass incoming emails to a flow.

Step 2: Install Find Text Extension

This is needed to extract the recordId from the email notification that approval processes send out. Here, you can see the id that we need to extract:

Step 3: Generate the ‘Resolve Approval Process’ Invocable Action

Follow the instructions here to generate a Resolve Approval Process action that can be used when the AutoApprover User is assigned a step.

Step 4: Create an autolaunched flow that will autoapprove an approval request

This flow uses the Find Text and Resolve Approval Process actions from the steps above:

To create this flow, do the following:

4.1 – create the following input variable to receive the body of the email notifications:

4.2 – configure the Find Text action to extract the 15 character ID of the approval process from the email notification

4.3 Configure the Resolve Approval Process to carry out an automatic approval

Note the the ‘foundString’ output from the Find Text action is mapped into the ‘approvalRequestId’ input here.

4.4 Don’t forget to activate the flow. 

You might want to test it out at this point by passing it an email body and verifying that it approves the specified approval request. 

Step 5 Update the the Email2Flow apex class to point to your newly created autoapproval flow

When you installed  EmailToFlow in Step 1 above, the package included an apex class called EmailToFlow that gets called by the Email Service and invokes a specified flow. As installed, that class attempts to call a test flow called ‘EmailController’. You need to hand-edit the Apex class in two places to point it at the flow you created above in Step 4. Here’s an example of a class that has been modified to point to a flow called Auto_Approve_Request:

At this point, you can carry out final testing.

Appendix – Troubleshooting

It can be a little tricky to assign an Email Service generated email address to a Salesforce User because of the various confirmation emails that can get sent out. You often need to look at error messages or debug text to find important links or codes. In the following image, when an existing user had their email address changed to be an Email Service address, a confirmation message was sent which generated an error email. Clicking the debug link made it possible to find the necessary confirmation link:

If you have too much difficulty getting this to work, an alternative is to give the auto approver User a free public email address or a corporate email address and then have that account auto forward emails to the Email Service account.

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).


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.

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

Easily Extract Substrings & Tap the Power of Regex with FindText

Suppose you have a message like this, generated from an email you’ve received…

“User User has requested your approval for the following item:

Please click this link to approve or reject this record.

Thank you,

…and you need to extract that recordId. In the scenario that inspired FindText, the goal was to use Flow to auto-approve the approval request represented by that recordId.

If you’re comfortable with formula functions, you can use them to pull the string out. We wanted to make it a little easier, so we created FindText. This initial version of FindText is quite limited as it will only find a string of a specified length that follows a specified prefix string. So in our example, we’re able to pass in the string along with these specific values:

This action, when passed the above email body, returns ’04i0U000000e9je.

The action outputs two values:

  • foundString &
  • foundStringCollection

foundString will contain the first hit and is useful if you’re only expecting a single hit. foundStringCollection will contain all of the hits.

See this action in action in this Approval Process example.

Future Development

Searching by length and prefix is only one of hundreds of ways you might want to extract substrings. Feel free to request other modes of query in the comments here.

Developer Notes

This action uses Salesforce Apex regex. Ideally, it will become the friendly way for flow creators to tap into the power of regex


v1.0 11-26



Connect Powerful Einstein Discovery AI To Your Flows

Two recent articles highlight new tools to connect AI predictions to Flow. This one is by Salesforce Director of Product Manager Bobby Brill:

This one by Salesforce engineer Alex Rich focuses on the use of the PREDICT formula function. His example shows PREDICT being used in Validation Rules, but the same use case is pertinent to the use of formulas in Flow:

From Jessie Rymph: How to display or upload a contact photo using Flow

Jessie Rymph over at her blog on Unhandled Sunshine posted a nice tutorial on how you can create a flow that lets users upload a contact photo or display their existing photo in a nice, clean, code free way utilizing Narender Singh’s File Preview component.

Check it out

From Tamar Erlich – Submit an orchestration from a button

Currently there are two ways you can launch a flow orchestration: using a record trigger, or auto launch from Apex, But what if I want to be able to launch an orchestration from a button and mimic the good old “Submit for Approval” button?
I looked at alternative ways to start orchestrations, and this is what I found:
1. Launching an orchestration from a URL button was not user friendly as the user was presented with a blank auto launched flow screen and was not redirected back to the record when finished even if the the return URL was part of the button definition. Overall, while this may work, the user experience was not smooth
2. Trying to include the submit flow as an interactive step assigned to the current user, resulted in a warning when saving the flow and an error during execution saying that no assigned user was found

I ended up with the following solution that worked well and gave a smooth user experience:

1. An action button to launch the submit flow on the record page
2. A submit screen flow that will update a field on the record to indicate the record was submitted and who the approver is
3. An orchestration that will listen to the field updated by the submit flow and will run the approval flow, routing to the approver that was updated on the record by the submit flow
4. The approval flow will update the record again with the final approval status

Here is an illustration of the overall process:

Both the submit and approve flows are very simple and only have one screen followed by an update records step

Submit Flow

Launch the submit flow from an action button added to the page layout

Action Button
Approval Flow

The flow orchestration only has one stage and one step

Orchestration Flow

It starts when the record’s approval status is updated to submitted

And routes the approval to the username that was updated on the record by the submit flow

Here is a short video demonstrating the complete process

Some notes about the flows:

1. The submit flow clears any previous approval status and rejection notes
2. The approval flow only displays rejection notes if the user selects to reject, using a visibility rule
3. In both flows, I’m using a record input variable and this saves having a get records element in the flow as the whole record gets passed in from the button or from the orchestration step

Possible enhancements:

1. The approval request flow can include a message with approval details to the approval request flow by using a display text with merge fields from the record and related records information
2. The submit flow can select the approver automatically by using criteria from the record or an approval matrix stored in custom metadata
3. The submit flow can also be used to recall or not allow to submit an approval by displaying another screen based on the approval status

Launching an orchestration from a button opens up a lot of possibilities, please share if you come up with other use cases.

From Ryan Mercer: Yet More File Upload Improvements

From Ryan Mercer: “I’m excited to release my next sprint of File Upload Improved. Thank you to everyone for your feature suggestions, I really enjoy working through your great ideas! Please continue to keep them coming.”

This release’s features include…

Show files below the component

By default, the files will show above the File Upload Component. If you’d prefer they be shown below the component, set this to TRUE.

Restrict users from uploading multiple files

Allow the user to upload multiple files. If this is not TRUE, then once the user uploads one file, the file upload component will not allow any additional files to be uploaded.

Control whether uploaded files are visible to all users

By default, when an internal user uploads a file, the file is only visible to other internal users (meaning community users can’t see it). If you’d like to make the uploaded file visible to all users, set this to TRUE. When a community user uploads a file, the file is already visible to all users.

From a technical perspective, this sets ContentDocumentLink.Visibilty = AllUsers.

Modify or Enhance The Names of Uploaded Files

The file name of the uploaded files defaults to the actual name of the file. If you’d prefer to override the default file name, you can specify the new file name here.

You can do funky things here like using a Text Template (remember to View as Plain Text) or even using a Flow Formula

Show Existing Files Related to Record Id

If you’d like to show the existing files associated with the Related Record Id (in addition to the ones that the user may upload), set this to TRUE. Be aware that sharing rules are NOT enforced, so the user could see files that they wouldn’t normally have access to.

Plus other general performance and architectural improvements

Install here.

From Tom Hoffman and Automation Hour: Manage Enterprise Territory Management with Salesforce Flow

It’s always great to see someone like Tom go deep on the use of Flow for a particular corner of Salesforce. Enterprise Territory Management is a core element of Sales Cloud, and this Automation Hour shows how to automate easily.

Check it out!

Recent Changes to Help Text in Screen Components

This is a memo from the Flow product team.

Some customers have noted that, for some screen components, the behavior of the help text button recently changed from “hover to see help” to “click to see help”. Here’s some background behind that change.

Originally, all Flow screen components supported formatting, embedded images, and embedded links in their helptext. They were written in Salesforce’s older Aura framework. They always required a click to open. Here’s the familiar UI that allows customers to create elaborate help content for each screen component:

Over the last 2 years, we have been converting the Aura components to use Salesforce newer and recommended Lightning Web Component framework. There are a lot of reasons to embrace the latest core Lightning technology like this, but sometimes there are side effects if the behavior of the new ‘base’ components provided by the framework doesn’t match the older behavior, and this is what happened with Help behavior. In LWC, the base help system uses tooltip semantics, causing the invocation to be on a hover but lacking support for rich text, embedded images, or embedded links. So for the last year or two, some screen components have had help bubbles that activated on hover.

After a few of the screen components were converted, some customers reported in that their investments in rich help were getting lost because the new hover text couldn’t show anything beyond plain text. Part of that is a mechanical limitation: with hovering behavior, if the hover text bubble has a link in it, you can’t click on that link because as soon as your cursor moves off of the triggering icon, the hover text goes away.

As a result, the Flow team has changed the behavior of its LWC screen components to use a popover. As part of this design, the popover is implemented with a click. While it’s possible to enable the popover to be implemented with a hover, we’d have to put a button next to the help icon that would enable users using screen readers and/or keyboards to have something to focus on, and so having to have two different visual elements side by side seemed unnecessary.

However, if there are users out there who really prefer the hover behavior, we’d like to hear more about that.

Give 5 Minutes – Take the Screen Flow Survey!

The Salesforce Flow team recently opened up an informal survey to get the community’s thoughts and feedback to help drive the future of Screen Flows. They would greatly appreciate 5-10 minutes of your time!

Check it out