This 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.
1 Define a button for events with these atributes:
Display Type─List Button
behavioue - execute javascript
content source - onclick javascript
add this 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 button to activity list views
3 add button to to any page layout that contains an activity related list. The button deletes any selected task or event in the list.
Getting Record IDs
This example creates a button that opens a popup window listing record IDs for user selected records. This is useful when testing to ensure you have the correct record IDs before processing them further.
1 Define a button for events with these atributes:
Display Type─List Button
behavioue - execute javascript
content source - onclick javascript
add this code:
idArray = {!GETRECORDIDS($ObjectType.Contact)};
alert("The Ids you have selected are: "+idArray);
2 add button to to the appropriate related list on a page layout or list view layout.
Get Google Map
This example creates a button that opens a new window showing a google map. This is useful for anyone wanting to make a site visit.
1 define a new button at customise - accounts - actions links buttons with these attributes:
Display Type─Detail Page Button
behavioue - display in new window
content source - URL
add this code: