Akihiro Iwaya Explores Approval Use Case in Flow Orchestrator
Intro
Flow Orchestrator takes a wide range of rich, sophisticated, and complex business process use cases that require code today and makes them easy to create with clicks. It makes it possible to automate multi user processes so I try to verify if Flow Orchestrator replaces the standard approval process.
Use case
A SaaS company provides various products with their customers. They give free trials for their products to their prospects and manage this process using a custom object called “Free Trial”, which contains Start Date of trial, End Date, Products, and related Opportunity.
The Sales VP would like all Free Trial requests to be routed controlled by an Approval Route table which is a custom object and it to be routed with serial and parallel mode.
Functionality
- Send an email to approvers
- Lock & unlock a record
- Three Approval Steps
- Serial mode : same as standard approval process
- Parallel mode
- Majority Wins
- CEO Overrides where a particular approver can override the majority
- Approval History
- Approval Route
- Custom Notification for only parallel mode
Demo Video
Flow
AI Approver Screen
This is a screen flow where an approver decide to approve or reject and return result parameter (approved is 1 otherwise 0)
AI Requester Screen
This screen flow receives is_approved (boolean) and recordId (string) as input parameters and update a Free Trial record’ status based on is_approved value. In case it is rejected, Apex action for unlocking the record is executed. Finally it shows whether the approval process is accepted or rejected to a requester. This implementation looks weird to you because the status of the record is updated after the requester executes this screen flow. Yes, it does. The current Flow orchestrator supports only screen flow. We can not hook up an event where three approvers complete their decisions for parallel mode (send approval request to approvers simultaneously) Do not worry about it. Flow orchestrator will support Autolaunched Flow soon. Once it comes true, we can get rid of updating and unlock record logics from this screen flow.
AI Submit Approval Process Action
Custom action of Free Trial record calls this screen flow. After requester completes to submit for approval process, Submit_Approval__c of the target Free Trial record is set to true. This triggers AI Approval Process Orchestration.
AI Parallel Approval Decision Flow
One of my favorite features of Flow orchestrator is that we can customize how a step or a stage will be triggered or considered complete. We can invoke an evaluation flow to evaluate the entry condition of a stage or step. This flow is an evaluation flow for parallel mode. An evaluation flow must be Autolaunched Flow and returns isOrchestrationConditionMet parameter (boolean). Since autolaunched flow can query objects and make API calls via Apex , execute logic, and so on, you can make complicated decision logic.
The flow receives parallel decision mode (Majority wins or CER overrides), role names for three approvers, three approver’s decisions, and “from approved stage” ( boolean value, from approved stage or rejected stage) as input parameters and returns isOrchestrationConditionMet boolean value. The current Flow orchestrator does not support evaluation flow within the Decision element so I need “from approved stage” input parameter so that only proper step is triggered. I will jot about this at AI Approval Process Orchestration section below.
AI Approval Process Orchestration
It is Record-Triggered Orchestration where object is Free Trial and condition is Submit_Approval__c Equals true. It orchestrates AI Parallel Approval Decision Flow, AI Submit Approval Process Action, AI Requester Screen, and AI Approver Screen.
Serial mode
Parallel mode
As I mentioned necessity of “from approved stage” input parameter at AI Parallel Approval Decision Flow section. I want to execute either a Work step named “Approved” or “Reject”. For instance, AI Parallel Approval Decision Flow returns true at Work step named Approved and do false at Work step named Rejected under approved Free Trial record.
Not implemented
- Recall approval process
- Assign Queue
- This can be implemented using Select Id from Group where type=’Queue’ and Name=’Queue Name’ and Select UserOrGroupId From GroupMember where GroupId =:Id but complicated
- Custom Notification for serial mode
- Supporting Autolaunched Flow will fix easily
Conclusion
I have confidence in replacing the approval process with Flow Orchestrator because I believe that new functionalities related to the approval process will be available at GA. My implementation of the approval process is a little bit complicated because of lacking standard functions such as supporting Autolaunched Flow, recall approval process (back to previous stage), standard actions (lock & unlock record, get queue member) but I am very excited to continue to watch new features.
You want to try?
Prerequisite
- Unlimited, Enterprise, Developer Editions have Flow orchestrator enabled
Package Installation
- Check https://youtu.be/DhnkMsQwImA at youtube for install package
- Go to https://sforce.co/3qEh40g
- Enter your credentials for your org
- Select “Install for All Users” at Install AI Flow Orchestration Approval Process screen and hit Install button
Post Installation
- Setup → Process Automation → Process Automation Settings
- Check “Allows Apex code to set and remove approval process locks. Enable record locking and unlocking in” checkbox
- Hit Save button
- Setup → Users → Profiles
- Search “Demo Salesforce Platform” profile
- Hit edit link
- Check the both “Run Flows” and “Send Custom Notifications” checkboxes
- Hit Save button
- Setup → User Interface → Path Settings
- Hit “Enable” button
- Create three “Salesforce Platform” user license users with “Demo Salesforce Platform” profile
- By Hand
- Role must be specified and one of three must be CEO role
- By Hand
- By Apex code
- Open developer console
- Debug→ Open Execute Anonymous Window
- Aki.createUsers(‘YOUR_REAL_EMAIL_ADDRESS’); and Hit Execute button
- You will receives password reset emails for three users at YOUR_REAL_EMAIL_ADDRESS.
- Select “Approval App” at App Launcher
- Select “Approval Route” tab
- Hit New button
- Create a Approval Route record
- Approval Route Name : High Priority
- Approver1 : one of users created at post installation step
- Approver2 : one of users created at post installation step
- Approver3 : System Admin user
Demo Steps
Requester
- Login in as the user which is not in the Approval Route record you defined
- Select Approval App at App Launcher
- Select Free Trial Tab
- Hit New button
- Fulfill fields
- Opportunity in the form is a custom object because “Salesforce Platform” user license user can not access standard Opportunity
- Hit Save button
- Hit Approval Process Action
- Fulfill all fields because I do not implement proper error handling ;(
- Check if the record is locked
Approver
- Login in as the user based on the selected Approval route record
- Select Approval App at App Launcher
- Select Free Trial Tab
- Select the record
- Enter your decision at the Work Guide
# The custom notification is not implemented for serial mode and you need to refresh a Free Trial detail page to change status after requester confirms at Work Guide
Uninstall Package
Since the uninstall package contains flow orchestrator, you need to delete some components manually first.
Please check https://youtu.be/mwIVAZb9pVA at youtube for uninstall the package