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

How to create a Approval Process by Apex



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. 





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 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.




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. 



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


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

Rahul SherikarRahul Sherikar
Hi zaidy,

Did u get any solution for this?
If yes then please post, it will be very helpfull.
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.