How to Guide Users Submitting Records for Approval with Visual Flow

I’ve often thought that the Submit for Approval Button in Salesforce could use some work.  It really doesn’t give the User any good information for why they might not meet the criteria for submitting their record for approval.  Isn’t there a better way?  I think so!  With the use of Visual Flow we’re able to guide the User through a tailored experience to help them submit their record with ease!

We’ll do this by querying the record(s) that we need to access, and then using decisions to determine what might be missing and present the User with the option to update the key fields missing.  In my example I’ll just keep it simple by looking for the Amount field.  If they haven’t filled out that value already, we’ll ask for them to update the Opportunity with the Amount before they can proceed to submitting the record for approval.  Let’s get started!

Navigate over to create a new Flow. (Setup | Create | Workflows & Approvals | Flows)

New Flow

The first step is going to be grabbing our Record Lookup.

drag-oppty

We’ll need to set the Record Lookup to find the Opportunity that matches the Opportunity ID variable we setup (and pass in through our Button – see How to write a Button URL for your Flow if you need a refresher on this).

var_oppid

I’ll also create a variable to store the Amount of our Opportunity.  This will allow us to reference the value.

opprecordlookup

Note:  We could technically pass additional values in our Button, or any number of fields that we want to (besides Currency to Currency, is a limitation within URL).  Regardless of the ability to do it or not, I like to try and keep the complexity in one spot (in the Flow), as opposed to multiple (the Flow and Button).  Also, we’re not expecting this to run in batch as it is only going to happen when a User clicks the button, so we’re not as worried about an extra query (typically).

Alright, so we’ve got our Amount field.  Now, we want to drag in our Decision Element to determine if we found a value in it or not.

amountDecision.jpg

For our example, all we need to check is if the Amount is greater than 0.  We’ll use the Default Outcome in this scenario to take our User to a Screen to fill out the Amount before we submit for approval.  If we were checking multiple fields, this decision logic could get more complicated (depending on how customized you wanted to the experience to be).

AmtGreaterthan0.jpg

I enjoy finishing a part of any automation I setup, so lets drag in our Submit for Approval Element and knock out this part of our Flow.  Then we can worry about the Default Outcome routing.

Submit for Approval drag.jpg

All you have to do is pass in the Opportunity ID as the Record ID.  Nice and easy!

oppsubmitforapproval

Great, so let’s jump into the other route of the Decision, when someone needs to fill out the Amount of their Opportunity.

DragScreen.jpg

On our Screen, we simply give a nice message to our User alerting them of what is expected.

ScreenAmt.jpg

I would recommend passing in variables like the Opportunity Name, Account Name, and other key fields into your Text Template.  You want the User to be confident of what record they’re currently updating.

We’ve now got to drag out a Assignment Element and update our Amount variable with the entered Amount.  I like to use Assignments after Screen Elements so that if I’m using multiple Screen Elements I can consolidate the values into one variable.

AssignVar.jpg

Now, make sure you’re setting the variable value to the Screen Input field correctly.  It can be easy to make a mistake here and assign the wrong value!

varassignment

We’ve now got to drag out a Record Update and update our Opportunity with the entered Amount.

dragupdate

Now we just need to add in the Amount field to our Record Update.  We can use the Amount variable here, because we just assigned the Screen Input value to that variable.

recordupdateop

From here, I find the easiest thing is to just route this back to the original Decision and see if it meets the criteria to proceed on.  You can determine how strict and customized you need your routing to be, but if you can keep it simple try to do so.  Mapping the Record Update back to the Decision Element gets us our finalized Flow.

FinishedSubmitFlow.jpg

Let’s Save the Flow and then Activate it.

save-flow

activateflow

Now, let’s go create a new Button on our Opportunity   (Setup | Customize | Opportunities | Buttons, Links, and Actions)

newButton.jpg

For the Button you’ll want to go grab your Flow’s URL.  This was on the Flow Detail page.

FlowURL.jpg

Paste that in, and we’ll add in the variable assignment for our Button.

action

Save, and then drag the Button onto your Opportunity Layout.  You’ll want to check the API Name when you hover over the Button to ensure you’ve selected your Custom Button and not the Standard one.

Add To Layout.jpg

All that is left is for you to test it out!

SubmitForApprovalFlow.gif

Hopefully this post was able to stir up some ideas of what is possible for you to do within your own Org!

 

 

 

 

 

 

 

 

How to Submit for Approval in Visual Flow

You have the ability now to submit records for approval in Process Builder.  This is one of those cases where we pretty much have the same functionality in Process Builder as we do in Visual Flow.  So that means, if its a simple submit for approval scenario, Process Builder will be the right tool for you!  However, if you need to try and make it more dynamic or simply fit it into an existing Visual Flow that you are using, then this Static Action will be your new best friend!
Depending on how many Flows, Quick Actions, and Email Alerts you have in your Salesforce, you might not notice the Static Actions section at the bottom of your Palette.  In here you’ll find a list of all three Static Actions.  We are going to be using Submit for Approval.

Great, we found our Submit for Approval., so lets drag it onto our Flow’s Canvas.

DragtoCanvasSubmitForApproval.jpg

If you notice, the only thing that is required for us to submit this for approval is the Record ID we want this to be triggered on.

RecordIdApproval.jpg

More often than not you’ll want to use some of the additional options with this element.

Submit for Approval Parameters.jpg

So, lets take a look at what those other parameters are:

  • Approval Process Name or ID
    • This allows you to enter the approval process Name or ID that you want to start
    • Leaving this parameter blank will cause the first Approval Process where the Entry Criteria is met to be selected
  • Next Approver IDs
    • Can either be a User ID or a Public Group ID
  • Skip Entry Criteria
    • Allows you to skip the Entry Criteria of your Approval Process
    • If you mark this as TRUE, make sure you specify the Approval Process if there is more than one.
  • Submission Comments
    • If you want to add comments that accompany the submission
  • Submitter ID
    • The User who is ‘submitting’ the record for Approval
    • Default is the Running User

Now we are able to set those parameters and when we hit this element the record will be submitted.  The cool part of this is we can also get pretty creative with what happens AFTER it is submitted for approval by using the Outputs tab, and assigning a parameter to a variable to be referenced after the record is submitted.

SubmitForApprovalOutputs.jpg

So, lets take a look at what our Output parameters are:

  • Instance ID
    • ID of the Approval Process Instance.  You can find this Object labeled ProcessInstance.
  • Instance Status
    • The Status of the Approval.  The four values are: Approved, Rejected, Removed, and Pending.
  • New Work Item IDs
    • A record(s) of work item(s) related to the next step.  Note, you can find this Object
  • Next Approver IDs
    • The next User(s) listed as an approver.  Just like the Work Items, this is potentially a collection of Users, so keep that in mind if you’re planning on working with it!
  • Record ID
    • This is the ID of the record that has been submitted for Approval.  Not of much value, which is why you see it listed last 🙂

 

For a quick summary, if you’re doing something basic with submitting for approval, go with Process Builder!  If you’ve got an existing Flow that you want to incorporate Submitting for Approval in, say you’re using a Visual Flow, then this is a great solution for you!