Supercharge your business processes by combining your Salesforce approval processes with the power of Salesforce Flow. With Process Builder and workflow rules being retired slowly but surely, Flow remains the Salesforce automation tool which leverages point-and-click functionality as a reliable alternative to writing custom Apex code in such scenarios.
Approval processes on the other hand have been around for a longer time, and while they have a very specific functionality to automate, respectively asking users to approve records, they are very user friendly and fast to configure as needed.
This post will cover a specific business need: launching an approval process automatically, without manual intervention from an user. In addition to this, we will showcase every step of the way, including the user’s experience when the automation is triggered.
Getting Started With Flow
If this is the first time you will be building a Salesforce flow, make sure to check out our guides below which cover all the basics for you to get started (and more!), as well as the dedicated Trailhead resources.
- The Complete Guide to Salesforce Flow
- A-Z Guide to the Salesforce Flow Builder
- Migrate to Salesforce Flow Course
- Ultimate Salesforce Flow Foundation Course
- Ultimate Guide to Building Salesforce Approval Processes
Why Would You Need This Solution?
Overall, similar to most automations, the reasons behind this solution include:
- Removing the need to manually click the Submit for Approval button.
- Ensuring the assignment of records which should be reviewed, approved or rejected by an assignee is happening as soon as criteria is met.
- Making sure that updating data as part of the automation following the outcome of the review is standard practice.
Let’s get to building!
Part 1: The Approval Process
Since I’m working in a new developer edition, there wasn’t any existing process on the opportunity object, so the first step is to go through the creation of the approval process from scratch.
Before we proceed, note that I will only briefly cover some of the steps when it comes to creating an approval process, and it will be a very simple one to exemplify the automation. For a thoroughly explained end-to-end scenario, make sure to check out our Ultimate Guide to Building Salesforce Approval Processes.
After navigating through Setup and onto the Approval Process page, choose your object to be an opportunity, and let’s proceed with the creation of the new process.
You will have to define a name and set the entry criteria, editability properties, and approval page layout. In this particular org and example, all opportunities are created in Prospecting when opportunity owners should enter a placeholder amount before progressing to Qualification.
For the approval step, feel free to use whichever example makes sense for you – be it one or multiple steps.
Once this is done, we can add the actions the process should take (eg. Email Alerts, Field Updates, etc.):
Once you’re happy with the approval process and steps, make sure to activate the approval process. Keep in mind that once it is activated, you will be able to change a few attributes in the approval steps, but you will no longer be able to delete them.
At this point (or at a later time), you can add actions such as Field Updates or Email Alerts, for either the Submission, Approval, Rejection or Recall. Also, each approval step can have its own actions.
Keep in mind that Salesforce allows us to create multiple approval processes on the same object. The recommendation they give is to always use exclusionary entry criteria so that they do not interfere with each other according to their order of execution. Basically, this means that you should not reuse the same entry criteria for more than one approval process.
In addition, each process can be reordered according to our needs, so you can always return to this page and change their process order numbers.
Part 2: The Record-Triggered Flow
Note: The tutorials we are showcasing are built in developer edition orgs with limited data and only a few custom automations. Ensure that you evaluate your existing processes properly before building new ones, including both declarative automations and custom Apex. For Flow specifically, consider the recommended best practices when it comes to the number of record-triggered flows per object.
The flow itself is quite straightforward to build, with a few specific attributes to set for the Submit for Approval action, such as defining the approval process’ name or ID. You can check-out the full list for this core action here.
Check out the short video below for the end to end Flow setup.
Note: In my hypothetical use case, opportunities can’t directly be created by users in Qualification or any stage other than Prospecting, hence why the flow only triggers on updates.
The flow below was built in a Spring ’23 developer org, and the visible element description directly on the canvas is one of the new additions available in the new release. Check the hottest Spring ’23 Flow features here.
Now as soon as the amount and stage on an opportunity record are updated to meet the criteria, the record will be submitted for approval!
Part 3: Let Your End Users Know What’s Happening
As I mentioned above already, the entire goal of what we’re doing is to save even more time for our users by removing a step and prevent potential errors such as the Submit for Approval button not being clicked.
One difference between this background automation and the manual process is letting the user know that the record is not pending approval, in case we decide to lock it and they’re wondering why can’t they edit it.
There are a few other options to explore here as always, varying from simple ones such as sending them an email to more complex ones, but I preferred to use the out-of-the-box Rich Text Lightning Component on the opportunity record page to announce that this is happening.
The reason I find this very handy overall is because it’s easy to set-up and filter to make it show up on the page based on criteria and filter logic and of course, and it’s easy to remove if it’s no longer needed.
Part 4: Don’t Forget to Test
There’s certainly nothing more fun after building a flow (or anything for that matter) than seeing that it works as expected. The Debug button does wonders after the flow is saved and before it’s activated, so that you can make any needed changes before activating the version you’re tweaking in case anything is missing and causing the flow to fail.
On top of the Debug button which helps us test the flow itself, now that the flow was activated, I also tested the behavior on the user interface just to make sure that the experience works exactly as expected from an user’s perspective. This was important to test since the changes I’ve made on the record page are independent from the flow.
Sometimes, testing might not go exactly as planned, and one very important aspect for this automation is, of course, to define the approver instead of trying to allow the opportunity owner to select it. Remember, they are not using the button, everything is happening in the background.
If this happens, a red error will let you know that this is the case in the UI, and you will also receive an email about the flow failing so you can easily make an update within the approval process or the flow.
Summary
After replicating and testing this end to end simple automation, you should feel more comfortable exploring the possibilities of combining both approval processes and Salesforce flows in your own sandbox or developer org. Considering the particular use cases you might want to leverage this approach for – the sky’s the limit!
Comments: