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
kkkkkk 

Submit approval process with Multiple records in apex

Hi everyone,

 

How can I submit for an approval for multiple records? I know that in SFDC org, we can only submit for approval with one records through the submit approval button.


Using apex class, I see that when we create an Approval.ProcessSubmitRequest, we can set the record Id in setObjectId. I didn't see any option that I can put multiple record on this class.

 

Can someone help me out for this? Maybe with overriding the class method from Approval class?

It would be great if you could also provide me with some code for overriding.

 

Thank you..

 

Jay

JitendraJitendra

Hi Jay,

 

There is no way that you can provide multiple records ID in Approval process. However you can loop through your records and submit for approval individualy using APEX.

 

Have a look non below article on submitting approval process using Apex:

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

 

kkkkkk

Hi Jitendra,

 

Thanks for your reply.

 

The problem for me, that after the user submit for a approval, there will be an email sent to the approver. And I want to avoid, that the approver will get spammed by each of those approval requests.

 

I could make a loop to create a request for all those records, but the approver still need to approve manually each of those records right? I would like to inform the approver only once, that with one click of approve button he could approve all those records.

 

What would you think the best way to solve this?

 

Jay

 

JitendraJitendra

Hi,

 

I dont think that there is any standard way to approve the record in bulk.

You will need to create custom code to approve records in bulk.

harsha__charsha__c

Hi Jay,

 

This can be achieved by a simple process 

 

You might be having an email alert on Approval process. Instead of that you can send a mail from the trigger itself, from where the records have been sent to the Approval Process

 

 

In that mail you can send a link of VF page [ Link contains all the Ids of Records that are sent to approval in csv format as Url param ], in which approver can be having option to approve all records at a time

 

In the VF page's controller query all records from approval processand which are related to the ids recieved through URL and display them in the page, Make a checkbox in the page so the approver can check all at a time and click on Approve button

 

Again on click of approve The controller mechanism will run and Approves the records through apex code

 

This might be a round process but this will be helpful in case of Bulk Approvals..!

 

Please let me know in case of Any concerns..!