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
ExpertNOTExpertNOT 

Approve a submitted record using Flow

Hi, Flow supports submitting a record for approval. I am trying to use flow to Approve and existing record in the approval process waiting to be approved. Any ideas. I see that you can up date a Process WorkItem in a flow but not the Process instance were the status is located. Di I have to write an Apex Class to change the processInstance Status to Approved and use it in the Flow?  I want to use a Flow as I have a collection of Records that are waiting for approval and use Flow to execute the approvals on the collection. 
Best Answer chosen by ExpertNOT
GauravGargGauravGarg
Hi Marty,

Please use below link.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_process_example.htm

Thanks,
Gaurav

All Answers

GauravGargGauravGarg

Hi Marty,

Yes, automate approving of aproval process can be possible with below situations:
1. Automate approval can only be possible through Apex.
2. We cannot use runAs() method within apex, i.e. system admin will be the user who will approve the user or the person who is approving it.
3. We need some criteria based on which we need automate approving process. 

Hope this information would be helpfull, let me know if you need more insight on this. 

Thanks,

Gaurav
Email: gauravgarg.nmims@gmail.com

ExpertNOTExpertNOT
Hi Gaurav,
OK I need to develop APEX along with my flow. I am thinking of developing an APEX Class using InvocableMethod, A flow can find the Process Instance and ProcessworkItem and I will have the TargetObjectID as well as the User ID in the flow. So all I need to do is figure out how to write an APEX Class as an InvocableMethod to approve .
GauravGargGauravGarg
Hi Marty,

Please use below link.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_process_example.htm

Thanks,
Gaurav
This was selected as the best answer
ExpertNOTExpertNOT
Thanks, I will use it as a basis for the APEX code.....
GauravGargGauravGarg
Welcome Marty, let me know if you face any issues. You can directly contact me on Email: gauravgarg.nmim@gmail.com