Loading
Prepare for Email to Become the Default Login ExperienceRead More
Salesforce Enforces New Security Requirements in Summer 2026Read More
Extend Salesforce with Clicks, Not Code
Custom Button Example: Get Record IDs

Custom Button Example: Get Record IDs

This example creates a button that opens a window listing record IDs for user selected records. Getting record IDs is useful when testing to ensure that you have the correct records before processing them further.

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

  1. Define a button with these attributes.
    Display Type List Button

    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 this sample code. This example is for contacts. Change the object type for a different type of record.
    idArray = {!GETRECORDIDS($ObjectType.Contact)};
    alert("The Ids you have selected are: "+idArray);
  2. Add the button to the appropriate related list on a page layout or list view layout.
 
Loading
Salesforce Help | Article