Loading
Prepare for Email to Become the Default Login ExperienceRead More
Extend Salesforce with Clicks, Not Code
Custom Button Example: Reopen Cases

Custom Button Example: Reopen Cases

This example creates a button that can be added to cases related lists so that users can reopen several cases on an opportunity at once.

Required Editions

Available in: Salesforce Classic

Custom buttons and links are available in: All Editions

Visualforce pages and s-controls are available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions

User Permissions Needed
To create or change custom buttons or links: Customize Application
  1. Define a button for cases with these attributes.
    Display Type List Button
    Behavior Execute JavaScript
    Content Source OnClick JavaScript
    Use this sample code.
    {!REQUIRESCRIPT ("/soap/ajax/13.0/connection.js")}
    var records = {!GETRECORDIDS($ObjectType.Sample)};
    var newRecords = [];
    if (records[0] == null) {
        alert("Please select at least one row")
    } else {
        for (var n=0; n<records.length; n++) {
            var c = new sforce.SObject("Case");
            c.id = records[n];
            c.Status = "New";
            newRecords.push(c);
        }
        result = sforce.connection.update(newRecords);
        window.location.reload();
    }

    This example references the AJAX Toolkit, which is available if API access is enabled. See https://developer.salesforce.com/page/Integration. Notice the check for records[0] == null, which displays a message to users when they don’t select at least one record in the list.

  2. Add the button to your opportunity page layouts by editing the Cases related list.
    Use this button on any page layout that contains the cases related list, such as account or contact page layouts.
 
Loading
Salesforce Help | Article