---
schema_version: "1"
id: 71e3be1fe9aa48e813f34fd8d47968331029945a559ae384313ea95d7145cd56
title: GETRECORDIDS
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/platform/264-0-0/customize_functions_getrecordsids.md
canonical_url: https://help.salesforce.com/s/articleView?id=platform.customize_functions_getrecordsids.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 7d84b00bf64d5e4d820cfc6ca4c6ffa006b5274508a095988c23cfba12a01da1
description: Returns an array of strings in the form of record IDs for the selected records in a list, such as a list view or related list.
products:
  - Salesforce Platform
  - Security
release: "264"
---
# GETRECORDIDS

Returns an array of strings in the form of record IDs for the selected records in a list, such as a list view or related list.

## Use

`{!GETRECORDIDS(object_type)}` and replace object\_type with a reference to the custom or standard object for the records you want to retrieve.

## Tips

- Use global variables to access special merge fields for s-controls, custom buttons, and links.
- Activities are special types of objects. Use {!GETRECORDIDS($ObjectType.Task)} when creating a task list button. Use {!GETRECORDIDS($ObjectType.Event)} when creating an event list button.
- This function is only available in custom buttons, links, and s-controls.

![Custom Button Example](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-extend_click-264-0-0-production-enus/5f7d9219-b7b1-4552-8891-f1aba9b289fc/images/icon_example.png)

Custom Button Example

```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();
}
```

In this example, all selected case records are updated with a Status of New. To set up this code in your org, create a custom list button for cases with these attributes.

- Display Type is List Button
- Behavior is Execute JavaScript
- Content Source is OnClick JavaScript

Paste this sample code into the content of your custom button. Finally, add the list button to the page layout that contains the Cases related list, such as accounts or opportunities. Users can select any number of cases in the related list and click the list button to change the status of those cases at once. 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.