Bulk Approval Request Using Apex in Salesforce

Bulk Approval Request Using Apex in Salesforce

 The Approval request in salesforce,users can submit the one and only record.The APEX  is used for Bulk Approval when the user needs to submit the multiple records

Step1: Create a Approval process with necessary action and assign the approver.

Step2: Create a Apex class with below mentioned code. We can able to submit more records in Apex.

public with sharing class submitBulkApproval {
    		public static void submitApproval() {
        		List<Approval.ProcessSubmitRequest> requests = new 
      	List<Approval.ProcessSubmitRequest> ();
     list<bank__c> BankList=[select id from bank__c];
       	 for (bank__c oppId: BankList) {
                  Approval.ProcessSubmitRequest req1 = new 
                  req1.setComments('Submitting request for approval ');  
        	Approval.ProcessResult[] processResults = null;
       	try {
                	processResults = Approval.process(requests, true);
        	}catch (System.DmlException e) {
                	System.debug('Exception Is ' + e.getMessage());

Step3: We can execute the code from anonymous window in the developer console or trigger.

After execution,the approval request record will send to approver mail.

Now the approver can approve the records which got from mail. 

Note: Approver only can see the approval request records in salesforce.