1

I am making a custom button on a list view so I can have users select multiple records and update 1 field from blank or false to TRUE. This is to kick off other actions. (this is in the customer community through VF)

Custom object is Part__c
Field to change Request_Update__c
Value to change to TRUE

{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")} 

var url = parent.location.href; 
var records = {!GETRECORDIDS($ObjectType.Part__c)}; 
var updateRecords = []; 

if (records[0] == null) { 
alert("Please select at least one record to update."); 
} else { 
var update_Part__c= new sforce.SObject("Parts"); 
update_Part__c.Id = records[a]; 
update_Part__c.Request_update__c = "TRUE"; 
updateRecords.push(update_Part__c); 
} 
result = sforce.connection.update(updateRecords); 
parent.location.href = url; //refresh the page 
}

If anyone can help I would appreciate this.

Thanks,

1

change

update_Part__c.Id = records[a]; 

will be update_Part__c.Id = records[0];


Complete code

{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")} 

var url = parent.location.href; 
var records = {!GETRECORDIDS($ObjectType.Part__c)}; 
var updateRecords = []; 

if (records[0] == null) { 
    alert("Please select at least one record to update."); 
} else { 
var update_Part__c= new sforce.SObject("Parts"); 
update_Part__c.Id = records[0]; 
update_Part__c.Request_update__c = "TRUE"; 
updateRecords.push(update_Part__c);  
result = sforce.connection.update(updateRecords); 
parent.location.href = url; //refresh the page 
}
| improve this answer | |
  • I still get an error "Unexpected token }" – Jason Feb 14 '16 at 9:32
  • @Jason use my Completed code.. – Ratan Paul Feb 14 '16 at 9:34
  • Finally got an actionable error. Your the man Ratan. – Jason Feb 14 '16 at 9:35

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.