Part I – 6.Types of Buttons in Salesforce



Every org has a unique set of business needs. If your users frequently need to access other pages in or outside your org, you can add custom buttons or links directly to object and record detail pages.

Custom buttons or links help you integrate Salesforce data with external URLs, applications, your company’s intranet, or other back-end office systems.

There are three primary types of custom buttons and links that you can create.

  • List button— Appears on a related list on an object record page.
  • Detail page link— Appears in the Links section of the record details on an object record page.
  • Detail page button— Appears in the action menu in the highlights panel of a record page.

 

This List Button example creates a button that can be added to activity-related lists and list views and allows users to delete selected records at the same time.

JavaScript custom buttons are available in all editions. However, the mass delete function described here doesn’t work in editions where the API isn’t enabled.

1. Define a button for events with the following attributes.

  • Display Type─List Button
    • NOTE Select Display Checkboxes (for Multi-Record Selection) so users can select multiple records in the list before clicking the button.
  • Behavior─Execute JavaScript
  • Content Source─OnClick JavaScript
  • Use the following sample code.
{!REQUIRESCRIPT("/soap/ajax/9.0/connection.js")} 

var records = {!GETRECORDIDS( $ObjectType.Event )}; 
var taskRecords = {!GETRECORDIDS( $ObjectType.Task)}; 
records = records.concat(taskRecords); 


if (records[0] == null) { 
alert("Please select at least one record.") } 
else { 

var errors = []; 
var result = sforce.connection.deleteIds(records); 
if (result && result.length){ 
var numFailed = 0; 
var numSucceeded = 0; 
for (var i = 0; i < result.length; i++){ 
var res = result[i]; 
if (res && res.success == 'true'){ 
numSucceeded++; 
} else { 
var es = res.getArray("errors"); 
if (es.length > 0) { 
errors.push(es[0].message); 
} 
numFailed++; 
} 
} 
if (numFailed > 0){ 
alert("Failed: " + numFailed + "\nSucceeded: " + numSucceeded + " \n Due to: " + errors.join("\n")); 
} else { 
alert("Number of records deleted: " + numSucceeded); 
} 
} 
window.location.reload(); 
}

2. Add the button to your activity list views.

3. Add the button to any page layout that contains an activity-related list. The button deletes any selected task or event in the list.

We are the ISV Partners and Please reach us for custom development => http://www.merfantz.com