Although this is very common approach and lots of articles are around on this topic, still I want to delineate the topic in other way. This topic covers complete scenarios for the approval process based on the Apex class.
Agenda of this article:
- Automatically submit the record for approval on the basis of field value.
- Automatically select the next Approver.
- Approve / Reject the record on the basis of field.
- Opportunity Object is used.
- Approval Process is already set on the Opportunity.
- Field “Next_Approver” will decide that who is going to approve the record.
- There are three steps in the approval process.
- There is no test class written and no check for mandatory fields needed for the trigger, as I have considered positive scenarios only.
API of Approval Process classes:
- Apex process
- Apex ProcessRequest
Steps of Standard approval process defined: