You are here:
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.
{!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.

