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
JosephtoJosephto 

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?

Message Edited by Josephto on 03-18-2010 07:38 AM
Best Answer chosen by Admin (Salesforce Developers) 
CaptainObviousCaptainObvious

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

imuinoimuino

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);

JosephtoJosephto
There was a space in there and I removed it but, I am still receiving the same error?
imuinoimuino
Which characters are instead of the smilie ;)
CaptainObviousCaptainObvious

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); }

 

This was selected as the best answer
JosephtoJosephto
That worked!  Thank you...