---
schema_version: "1"
id: cbbe95d4c8b309e743840355eec718d226639623fe8a4331baa09746d5fe8e3b
title: "Custom Button Example: Display Alerts"
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_displaying_alerts.md
canonical_url: https://help.salesforce.com/s/articleView?id=platform.links_useful_custom_buttons_displaying_alerts.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: b25ee65c27773d845abdbd16ceb63a0d8b08cd3f16b81c2f3f6eb4d25f90ce4f
description: This example creates a button that opens a window with a welcome message containing the user's first name.
products:
  - Salesforce Platform
  - Security
release: "264"
---
# Custom Button Example: Display Alerts

This example creates a button that opens a window with a welcome message containing the user's first name.

### 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="d79541e87">User Permissions
              Needed</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d79541e87 ">To create or change custom buttons or links:</td>

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

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

1. Define a button 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="d79541e114-option" id="d79541e118">Display Type</th><td style="vertical-align:top;" headers="d79541e114-desc d79541e118">Detail Page Button</td></tr><tr class=""><th style="vertical-align:top;" headers="d79541e114-option" id="d79541e127">Behavior</th><td style="vertical-align:top;" headers="d79541e114-desc d79541e127">Excute JavaScript</td></tr><tr class=""><th style="vertical-align:top;" headers="d79541e114-option" id="d79541e136">Content Source</th><td style="vertical-align:top;" headers="d79541e114-desc d79541e136">OnClick JavaScript</td></tr></tbody></table>
    
    Use this sample code.
    
    ```javascript
    alert ("Hello {!$User.FirstName}");
    ```
2. Add the button to the appropriate page layout.

#### 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.")