public PageReference deleteAll() {
// Delete all records here. list<CalloutConcentrator__c> allRecs = [select id from CalloutConcentrator__c]; delete allRecs; // Redirect to the List View. Schema.DescribeSObjectResult anySObjectSchema = CalloutConcentrator__c.SObjectType.getDescribe(); String objectIdPrefix = anySObjectSchema.getKeyPrefix(); PageReference pageReference = new PageReference('/'+objectIdPrefix+'/o'); pageReference.setRedirect(true); return pageReference; }
The button configuration:
It’s a LIST BUTTON.
Behavior: Display in existing window without sidebar or header
Content Source: URL
https://YourOrg.visual.force.com/apex/CalloutConcentratorDeleteAll
The Visual Force page:
<apex:page controller="CalloutConcentratorController" action="{!deleteAll}"> </apex:page>