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?


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;
    result = sforce.connection.update(updateRecords); 

This should work, I can think only of couple problems here:

  1. Are you on iPhone/iPad? There were some known bugs with GETRECORDIDS not working properly on iSafari (regular Safari seems to be fine).
  2. Are you sure the object name is typed correctly? It has 2 underscores = FF must be a managed package? Is current user allowed to edit them etc etc? (even if you're sysadmin objects might appear invisible - not returned in describe results if Profile permissions aren't set)
  3. Any validation rules /trigger-based checks you might be hitting over there? You're swallowing all results which might contain errors. Perform simple alert(results); or maybe sth like this:

for(var i = 0; i < results.length; ++i){
    if (result[i].getBoolean("success")) {
        log("record with id " + result[i].id + " updated");
    } else {
        log("failed to update record " + result[i]);

(inspect the browsers JS console afterwards or replace log with alert but then make sure to not tick too many checkboxes ;))

  • Thanks! there is an active trigger on the custom object. Let me take another look and even try my code (with your log addition) on another object I know has no triggers. Nov 30 '12 at 20:59
  • The JS console in Chrome revealed this error message: failed to update record {errors:{fields:null, message:'sObject type 'FF__Team_Member__c' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.', statusCode:'INVALID_TYPE', }, id:null, success:'false', } Nov 30 '12 at 22:46
  • @SteveRichardson Are you really really sure you haven't mistyped the object's name? It will have only 1 underscore after "FF' if it's your own custom object and not coming from an installed package. What's the "API" name if you view it in Setup (upper right corner) -> Create -> Objects. Are you sure you have "Read" and "Update" permissions to it (even if you're sysadmin - check your Profile)...
    – eyescream
    Nov 30 '12 at 22:50
  • I'm the package developer. This managed pkg is installed into a subscriber org. I'm working as a System Admin in the subscriber org. The API name from Setup is: FF__Team_Member__c Nov 30 '12 at 22:55
  • I've probably screwed it up but hopefully you got some notification about the chat room I tried to set up... chat.stackexchange.com/rooms/6573/…
    – eyescream
    Nov 30 '12 at 23:40

I was facing the similar problem of 'INVALID_TYPE' when trying to update an array of Cases. After a long time I found out that the sforce.connection.update method only takes a SINGLE object at a time for updation. Since we were both passing an ARRAY, the call failed. Try passing only a single record and it should work fine.

There has to be something though to work with a collection.


Please update this line, you forget to add the id.
update_TeamMember.Id = records[a].id;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.