I need to allow a user to select one or more records from a related list and click a button on that related list that sets a checkbox to true on each selected record.
I have prepared the following javascript in a custom button and displayed checkboxes in the related list.
Currently, when the button is clicked, the records are not updating and the checkboxes are not getting set.
Custom object: FF__Team_Member_c Custom field: Checkbox on FF_Team_Member__c : Send_Email_to_Team_Member__c
Any thoughts?
{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
var records = {!GETRECORDIDS($ObjectType.FF__Team_Member__c)};
var updateRecords = [];
if (records[0] == null) {
alert("Please select at least one record to update.");
} else {
for (var a=0; a<records.length; a++) {
var update_TeamMember = new sforce.SObject("FF__Team_Member__c");
update_TeamMember.Id = records[a];
update_TeamMember.Send_Email_to_Team_Member__c = true;
updateRecords.push(update_TeamMember);
}
result = sforce.connection.update(updateRecords);
location.reload(true);
}