You need to sign in to do that
Don't have an account?
missing ; before statement
I have written some code to update a check box from a custom button. However, I continue to get an error that says" "missing ; before statement"
Here is my code;
{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")}
var theId ="{!Contact.Id}";
var c = new sforce.SObject("{!Contact.Id}");
var objectsArray = [];
c.Id = {!Contact.Id};
Contact.Andon_Cord_Flagged__c = 1;
//Push the Update
var callCompleted = false;
objectsArray .push(c);
try{
var result = sforce.connection.update(objectsArray );
callCompleted=true;
}
catch(error){
alert ("En error occured : " + error);
}
if (callCompleted){
for (var i=0;i<result.length;i++){
if (!result[i].getBoolean("success")){
alert ("Error encountered while updating record id " + theId + " : " + result[i].error);
}
}
//Reload Window
window.location.reload(true); }
ANY IDEAS?
I havent tested this, but try the following:
{!REQUIRESCRIPT("/soap/ajax/18.0/connection.js")} var theId ="{!Contact.Id}"; var c = new sforce.SObject("Contact"); var objectsArray = []; c.Id ="{!Contact.Id}"; //If "Andon Cord Flagged" is a checkbox, //you may want to change the following line to: c.Andon_Cord_Flagged__c = true; c.Andon_Cord_Flagged__c = 1; //Push the Update var callCompleted = false; objectsArray.push(c); try{ var result = sforce.connection.update(objectsArray); callCompleted=true; } catch(error){ alert ("En error occured : " + error); } if (callCompleted){ for (var i=0;i<result.length;i++){ if (!result[i].getBoolean("success")){ alert ("Error encountered while updating record id " + theId + " : " + result[i].error); } } //Reload Window window.location.reload(true); }
All Answers
Hi Josephto
Isn't there an extra space on line 10 between objectsArray and .push(c)?
It should go without ant space
objectsArray.push(c);
I havent tested this, but try the following:
{!REQUIRESCRIPT("/soap/ajax/18.0/connection.js")} var theId ="{!Contact.Id}"; var c = new sforce.SObject("Contact"); var objectsArray = []; c.Id ="{!Contact.Id}"; //If "Andon Cord Flagged" is a checkbox, //you may want to change the following line to: c.Andon_Cord_Flagged__c = true; c.Andon_Cord_Flagged__c = 1; //Push the Update var callCompleted = false; objectsArray.push(c); try{ var result = sforce.connection.update(objectsArray); callCompleted=true; } catch(error){ alert ("En error occured : " + error); } if (callCompleted){ for (var i=0;i<result.length;i++){ if (!result[i].getBoolean("success")){ alert ("Error encountered while updating record id " + theId + " : " + result[i].error); } } //Reload Window window.location.reload(true); }