Skip to main content
Hi folks,

 

I've never worked with JavaScript before and I was trying to create a Custom Button for a list view by copying stuff from all over and just changing object/field names to my org's. Now I've a Frankenstein's monster of a script that doesn't work. :-S

 

The error I get when running the below is "onSuccess not defined in the callback".

 

The button's to be used in the list view for Jobs (ts2__Job__c). All I want it to do is uncheck Post Job (ts2__Post_Job__c).

 

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

 

var url = parent.location.href; 

 

var records = {!GETRECORDIDS($ObjectType.ts2__Job__c)}; 

 

var ts2__Job__c = sforce.connection.retrieve('Id','ts2__Job__c','ts2__Post_Job__c', records);

 

var updateRecords = []; 

 

 

 

if (records[0] == null) {

 

  alert("Please select at least one record to update."); 

 

} else {

 

 for (var a=0; a<ts2__Job__c.length; a++) { 

 

  var update_Job = new sforce.SObject("ts2__Job__c"); 

 

  update_ts2__Job__c.Id = ts2__Job__c[a]; 

 

  update_ts2__Post_Job__c = "False";

 

  updateRecords.push(update_ts2__Job__c); 

 

 }

 

 result = sforce.connection.update(updateRecords);

 

 parent.location.href = url; 

 

}

 

if(result[0].success=='true'){

 

    alert('The records have been update successfully.');

 

}

 

else{

 

    alert('An Error has Occurred. Error: ' + result[0].errors.message);

 

}
4 件の回答
  1. 2015年11月23日 23:21
    My suggestion is to not waste your time learning custom buttons and javascript for building features or functionality in the Salesforce UI.  Both are effectively being deprecated in light of the new UI and the new Quick Action features that have been released over the past couple of years.  
0/9000