function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
WebNXWebNX 

JavaScript error using Salesforce's custom button

Help!!!!! I keep receiving the following error message from Salesforce when I click on a custom JavaScript button that I built.
A problem with the OnClick JavaSecript for this button or link was encountered:
Expected ';'
I have created a custom Salesforce button using JavaScript to populate two custom fields in a custom object. The JavaScript queries all the related record’s counters and adds them up then updates the current record along with refreshing the web page. Below is JavaScript code that I am using, thanks in advance.
Clyde


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

var qyRecords = sforce.connection.query("Select Billable_Hours_NX__c, Non_Billable_Hours_NX__c From Project_Line__c Where Project__c = '" + "{!ProjectConnection__c.Project__c}" + "'", {onSuccess : success, onFailure : log});


functiion success(qyRecords){
var billHours = 0;
var nonbillHours = 0;
var records = new sforce.getArray("records");
for(var i=0; i<records.length; i++){
var record = records[i];
billHours += record.Billable_Counter__c;
nonbillHours += record.Non_Billable_Counter__c;
}
var precord = new sforce.SObject("ProjectBillableConnection__c");
precord.id = {!ProjectBillableConnection__c.Id};
precord.TotalLBH__c = billHours;
precord.TotalLNonBH__c = nonbillHours;

sforce.connection.update([precord]);
window.location.reload();
}
Ashish_SFDCAshish_SFDC
Hi , 


This looks like there is an Issue with some syntax failing an runtime on dynamic execution. 

Please enable debug logs for the user who is getting this error. 

Check if the issue is reproducable or Random. 

If npot reproducable then we have to check which combination or which criteria getting that error. 

Check the debug logs on the Line and Word where you are getting the error. 

http://www.salesforcegeneral.com/salesforcecom-debug-logs/


Regards,
Ashish