1. Create a Visualforce Page
In the Salesforce org, create a new Visualforce page.
Set the following:
standardController: The Salesforce object you want users to mass delete.extensions:GFCON.MassDeleteController
Copy and paste the code below. Replace GFERP__Sales_Price2__c with the API name of the object you want to mass delete.
<apex:page recordSetVar="" standardController="GFERP__Sales_Price2__c" extensions="GFCON.MassDeleteController" lightningStylesheets="true">
<GFERP:LoadingStatus />
<apex:sectionHeader title="Mass Delete Sales Price"/>
<apex:form id="theForm">
<apex:pageBlock id="thePageBlock">
<apex:outputPanel >
<apex:pageMessages id="theMessage"></apex:pageMessages>
</apex:outputPanel>
<apex:pageBlockButtons location="bottom">
<apex:commandButton status="loadingstatus" action="{!massDelete}" rerender="thePageBlock" value="Mass Delete"/>
<apex:commandButton value="Return" action="{!cancel}" />
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>2. Create a List Button
Create a new button for the same object.
Recommended settings:
- Display Type: List Button
- Behavior: Display in existing window without sidebar or header
- Content Source: Visualforce Page
- Visualforce Page: Select the Visualforce page created above
- Button Label: Mass Delete
- Button Name: Mass_Delete
Enable the option to allow users to select multiple records, when available.
3. Add the Button to the List View
Add the new Mass Delete button to the object’s list-view search layout.
Navigate to:
Setup → Object Manager → Object → Search Layouts for Salesforce Classic → List View
Edit the List View layout and add the Mass Delete button to the selected buttons.
4. Test the Button
Before making it available to all users:
- Open the object’s list view.
- Select several test records.
- Click Mass Delete.
- Confirm that only the selected records are deleted.
- Confirm that validation errors and permission errors are displayed correctly.
- Verify that the Return button brings the user back to the list view.
Because this operation deletes multiple records, test it with noncritical records and confirm that the appropriate user profiles have access to both the Visualforce page and the Apex extension.
Comments
0 comments
Please sign in to leave a comment.