+ Start a Discussion
David PoynterDavid Poynter 

How to create an Invocable Apex Class for Approving records

I probably should have asked this question long ago instead of spending a couple hours futzing around.

I am a newbie to Apex, however I do have some experience in Java.

The Use-Case: I would like to create a customized flow that is launched via a button to allow for editing a field and approving an outstanding approval process at the same time. (e.g. There are different approval types in our industry, and instead of just approving, we are trying to be able to have a flow to select the type of approval and approve it in the same action)

I have tried creating invocable methods with invocable variables (so that the visual flow can call on it and pass an Id to it), but the whole limitation of only sending lists of objects in an InvocableMethod is really throwing a wrench in the system. I just want to pass a single Id that the ProcessInstance.TargetObjectId is equal to to approve.

These are the resources I have been using so far:
And of course the Invocable Variable/Method anotation content from salesforce.

Please please help. I would love for this to be the first success story of apex in our Org.