Mass Approval | Approve/Reject Multiple Records at once

Suyash N
Suyash N 2.2k Views 4 comments

Approving multiple record one by one is a painful activity. You have to open each record, click Approve & then give comment. Mass Approval lightning component will provide you a greater efficiency for this.

With this component you can see all Approval requests pending on the login User. And you can multi select and approve them on a single button click.

Component Features:
  • Approvals of upto 25 objects can be seen. (Configurable)
  • Multi select records and approve/reject at once.
  • Ability to add comments before approving or rejecting.
  • Auto query Name field to have better understanding of pending records

One important thing to notice here is that to query multiple records, query is done in FOR LOOP. But that’s not a point of worry as you can hit 100 SOQL in single transaction and it’s just 25.

Component Preview:

Mass Approval of Approval Requests


Step-1: Create an Apex controller and Exception Class

We need to create an Exception class first to throw the custom exception and Apex controller which will fetch all pending Approval requests of the current Login User.

Create MyException.cls Apex class.

Now create MassApprovalController.cls Apex class.


Step-2: Now we will create the MassApproval Lightning Component.

For creating a new Lightning component, go to Developer console > New > Lightning Component. After creating the component, open the cmp file and paste the below code.

Markup for MassApproval.cmp

Notice that here we have used the CustomToast component on the 5th line. You need to include a custom toast component to show Toast Messages. You can check out the CustomToast component from HERE.

Approve/ Reject Approval Requests at once


Now open the javascript file MassApprovalController.js and paste the below code.

After controller, paste the below code in MassApprovalHelper.js

Now finally paste the CSS in the MassApproval.css file.


Step-3: Now we will call the component.

Finally, our component is ready to use. You can call this component in any other Lightning component or Lightning Application. Besides, you can place this component on Home Detail page or Record Detail page from Lightning App Builder. All Set Now. Approve as many request as you want.

Mass Approve Requests lightning Salesforce

Ability to add Approval Comments.

Bulk Approve Approval Request in Apex

Also Check:

For any queries or suggestions, comment below.

Cheers … Happy Coding … 🙂

Share This Article
Notify of
Inline Feedbacks
View all comments

How we can edit based on Case Object


Am getting component error when i try to add in the Lightning home page.

Unable to find action ‘fetchApprovals’ on the controller of c:MassApproval