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 Answer 1

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 
}
3
  • I still get an error "Unexpected token }"
    – Jason
    Commented Feb 14, 2016 at 9:32
  • @Jason use my Completed code..
    – Ratan Paul
    Commented Feb 14, 2016 at 9:34
  • Finally got an actionable error. Your the man Ratan.
    – Jason
    Commented Feb 14, 2016 at 9:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .