---
schema_version: "1"
id: de13ffdc2d4166977dd074a246673dd8b2273058d23f4ea07407562d454f0488
title: "Custom Button Example: Reopen Cases"
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/platform/264-0-0/links_useful_custom_buttons_reopening_cases.md
canonical_url: https://help.salesforce.com/s/articleView?id=platform.links_useful_custom_buttons_reopening_cases.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 294f3f7001420189a961e7743fb8a95d9a82415c810b5c88b555a7741edae7a9
description: 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.
products:
  - Salesforce Platform
  - Security
release: "264"
---
# 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

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition">
        <colgroup>
          <col>
        </colgroup>
        <tbody>
          <tr class="">
            <td class="slds-cell-wrap" style="vertical-align:top;">Available in: Salesforce Classic</td>

          </tr>
          <tr class="">
            <td class="slds-cell-wrap" style="vertical-align:top;">
              <p>Custom buttons and links are available in: <strong>All</strong> Editions</p>
              <p style="margin-bottom:0;">Visualforce
                pages and s-controls are available in: <strong>Contact Manager</strong>, <strong>Group</strong>,
                <strong>Professional</strong>, <strong>Enterprise</strong>, <strong>Performance</strong>, <strong>Unlimited</strong>,
                and <strong>Developer</strong> Editions
              </p>
            </td>

          </tr>
        </tbody>
      </table> <table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small permission">
        <colgroup>
          <col style="width:50%">
          <col style="width:50%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="colgroup" class="slds-cell-wrap" colspan="2" style="vertical-align:top;" id="d116417e87">User Permissions
              Needed</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d116417e87 ">To create or change custom buttons or links:</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d116417e87 ">Customize Application</td>

          </tr>
        </tbody>
      </table>

1. Define a button for cases with these attributes.
    
    <table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small "><tbody><tr class=""><th style="vertical-align:top;" headers="d116417e114-option" id="d116417e118">Display Type</th><td style="vertical-align:top;" headers="d116417e114-desc d116417e118">List Button</td></tr><tr class=""><th style="vertical-align:top;" headers="d116417e114-option" id="d116417e127">Behavior</th><td style="vertical-align:top;" headers="d116417e114-desc d116417e127">Execute JavaScript</td></tr><tr class=""><th style="vertical-align:top;" headers="d116417e114-option" id="d116417e136">Content Source</th><td style="vertical-align:top;" headers="d116417e114-desc d116417e136">OnClick JavaScript</td></tr></tbody></table>
    
    Use this sample code.
    
    ```javascript
    {!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](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.

#### See Also

- [Custom Button and Link Samples](https://help.salesforce.com/s/articleView?id=platform.links_useful_custom_buttons.htm&release=264.0.0&type=5 "Use samples of custom Salesforce buttons and links to determine whether they can work for you.")