+ Start a Discussion
zaidyzaidy 

How to create a Approval Process by Apex

Hi, 

 

Does anybody has an idea on how to create the whole Approval Process by Apex? I don't mean the Approval request by Apex, I saw few examples of the Approval request by Apex, but they are only effective when the Approval Process for a particular object is already defined. 

 

Any advice will be appreciated. 

 

Regards, 

 

Ispita_NavatarIspita_Navatar

Apex provides support for creating a programmatic approval process to extend your existing approval processes with the following:

The Apex process classes: Use these to create approval requests, as well as process the results of those requests. For more information, see the following:

- ProcessRequest Class

- ProcessResult Class

- ProcessSubmitRequest Class

- ProcessWorkitemRequest Class

• The Approval namespace process method: Use this to submit an approval request, as well as approve or reject existing approval requests. For more information, see Approval Methods.

For more information on approval processes, see “Getting Started with Approval Processes” in the Salesforce.com online help.

Since Apex proves for programmatic submission of records for approval , so one can easily extent it for having a functionality scaling multiple records.

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.

zaidyzaidy

Hi, 

 

Thanks for your reply. As you mentioned on your reply and it is also explained on the book apex_language_reference: "Apex provides support for creating a programmatic approval process to extend your existing approval processes", what happen when you need to create the actual approval process by Apex? 


Any ideas? Like, what is the object that stores approval process records, and also object that stores all approval steps, actions and object to store the relationship between the approval process and approval actions, so I create these records as required by the user. 


Regards,

gliustonecobragliustonecobra

I don't believe Apex supports this yet. this is more of a metadata API piece - there's an idea out there for this:

 

http://success.salesforce.com/ideaView?id=08730000000BqjD

JitendraJitendra

Its too late to reply however i hope the new users can get benefit from below article :

 

http://shivasoft.in/blog/salesforce/dynamic-approval-process-based-on-the-apex-and-trigger/

Rahul SherikarRahul Sherikar
Hi zaidy,

Did u get any solution for this?
If yes then please post, it will be very helpfull.
 
Thanks,
Rahul S. 
Björn Wiberg 4Björn Wiberg 4
I would create a Flow that starts an approval process and start the Flow from Apex.