function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jai SureshJai Suresh 

Approve using a Visual Flow

I am new to Visual Flow and have just started learning what and how.

In a record, I have to populate three lookup fields using Flow and before I end up in a final screen, if all the lookups are successfully populated, I have to approve that record else I have to send an error email to the record owner.

I have managed only upto populating the three lookups and now trying to find a way to accomplish the approval process through Flow without any manual intervention.

Thank you.
Best Answer chosen by Jai Suresh
Ashish_SFDCAshish_SFDC
Hi Suresh,


If you feel comfortable writing some Apex code, you could write a small class that creates the approval process, which you could call from the Flow using the Apex callout element.

E.g.
Apex Class: 'SubmitForApprovalPlugin' implementing the Process.Plugin interface
Flow calls 'SubmitForApprovalPlugin' using an Apex callout.
inputs to apex class (as a value table):
* Id (of the record to submit for approval)
* Comments (comments for the approval request)
outputs to Flow (as a value table):
* Success status (boolean)

References:
Developing an Approval Process in Apex: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_process_example.htm
Implementing the Process.Plugin Interface: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_process_plugin.htm
Designer user guide (there's a section for the Apex Callout element): http://www.salesforce.com/us/developer/docs/firefly/salesforce_flow_designer.pdf

https://developer.salesforce.com/forums/ForumsMain?id=906F00000008m3CIAQ


Regards,
Ashish

All Answers

Ashish_SFDCAshish_SFDC
Hi Suresh, 


"Salesforce's Workflows and Approvals are meant for manual work that can never be automated using APEX to replace the manual steps. Is that right?" 
Unless I misunderstand what you're saying, this is incorect.  APEX is more powerful than workflows/approvals, but approvals are are ready a pre-built engine for admins to easily create and modify.  APEX can do the same thing (and much more) that a workflow can do but takes someone who can develope them.

You should be able to create a visual flow that presents different options based on the users profile using Decisions.

Based on your description you would probably want to use triggers/approvals to create this process depending on how many users you have, flows are more of a guided process and may be confusing to end users in this situation - based on the info provided.   You can accomplish everything here except for creating the cases via workflow/approvals.

https://developer.salesforce.com/forums?id=906F00000009Au0IAE


Regards,
Ashish
Jai SureshJai Suresh
Thanks Ashish.

I do know that this can be accomplished by Apex. 
I basically wanted to know if we can kick off an approval process with Flow.
Ashish_SFDCAshish_SFDC
Hi Suresh,


If you feel comfortable writing some Apex code, you could write a small class that creates the approval process, which you could call from the Flow using the Apex callout element.

E.g.
Apex Class: 'SubmitForApprovalPlugin' implementing the Process.Plugin interface
Flow calls 'SubmitForApprovalPlugin' using an Apex callout.
inputs to apex class (as a value table):
* Id (of the record to submit for approval)
* Comments (comments for the approval request)
outputs to Flow (as a value table):
* Success status (boolean)

References:
Developing an Approval Process in Apex: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_process_example.htm
Implementing the Process.Plugin Interface: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_process_plugin.htm
Designer user guide (there's a section for the Apex Callout element): http://www.salesforce.com/us/developer/docs/firefly/salesforce_flow_designer.pdf

https://developer.salesforce.com/forums/ForumsMain?id=906F00000008m3CIAQ


Regards,
Ashish
This was selected as the best answer