There are times when we want to perform mass deletion of records on Salesforce object records. We might come across a scenario where we want to perform Mass delete of records on large number of records of particular object which would delete records in bulk. We checked in Salesforce and we found that this functionality is available in Salesforce only for standard Salesforce objects. What if I want this functionality for records of Custom Objects?
If you are aware of Salesforce Apex and Visualforce development knowledge you can use below set of code to get this done. Below is the function for Mass Delete which calls the action and performs deletion of records.
Steps to Mass delete records of a particular object in Salesforce:
- Write a Mass Delete extension/Controller using Apex:
In below code example, we have created Mass Delete button for deleting records of Account object. You can refer this code to do it for your custom object. Create a new Extension to Account object with name “MassDelete” and you can refer the below code.
- Create a Visual Force page to display list of records which you wants to Mass Delete:
Bind the above controller to Visual Force page and use standard controller list which allows you to create Visual force page that can display or act on a set of records along with RecordSetVar which not only indicates that the page uses a list controller, it also indicates the variable name of the record collection. You can set the standardController to the API name of the object you want to have this functionality for. Eg. If you want it for Contacts make it “standardController=Contacts”.
- Add the Mass Delete Button on the UI (Tab for the object)
- Go to that particular object selected for example in your case Account.
- Click on Button, Links and Action and create a button as given in below screenshot.
- Click search layout and go to that object’s List view. e-g Accounts List View
- Now button created appears on Available buttons and we need to add to selected button and click save.
- Finally, the selected button will appear on Object’s home page by clicking GO.
In image below, we have selected two records which get deleted on clicking Mass Delete button. In similar way, we can delete other records using Mass delete function.
About Us
Greytrix as a Salesforce Product development partner offers a wide variety of integration products and services to the end users as well as to the Partners across the globe. We offers Consultation, Configuration, Training and support services in out-of-the-box functionality as well as customizations to incorporate custom business rules and functionalities that requires apex code incorporation into the Salesforce platform.
Greytrix has some unique solutions for Cloud CRM such as Salesforce integration with Sage Enterprise Management (Sage X3), Sage Intacct, Sage 100 and Sage 300 (Sage Accpac). We also offer best-in-class Cloud CRM Salesforce customization and development services along with services such as Salesforce Data Migration, Integrated App development, Custom App development and Technical Support to business partners and end users.
Greytrix GUMU™ integration for Sage ERP – Salesforce is a 5-star app listed on Salesforce AppExchange.
For more information, please contact us at salesforce@greytrix.com. We will be glad to assist you.
Related Posts