0

I am trying to create a custom button on a detail page that updates a field on the record. Here is my code:

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

var newRecords = [];  

var idLob = new sforce.SObject(“Idea_Lobby__c”);  
idLob.id =”{!Idea_Lobby__c.Id}”;                  

idLob.Vote_Test__c =(’Up‘) ; 

newRecords.push(idLob);            

result = sforce.connection.update(newRecords); 
window.location.reload();

I get an illegal token error. Any ideas on what's going wrong? Also, can I call this button from a command button in a HTML visualforce page?

Thanks!

1
  • 1
    Is vote_Test__c a text val if so try idLob.Vote_Test__c = "Up" ;
    – Rao
    Commented Feb 4, 2015 at 18:51

2 Answers 2

1

Did you copy the script from an editor? I am just noticing the slightly slanted inverted commas, sometimes the encoding for the inverted commas is also copied along with the text. Just guessing as the script seems otherwise fine :)

0

The quotes were my problem. Here's the final code:

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

var newRecords = [];  

var idLob = new sforce.SObject(“Idea_Lobby__c”);  
idLob.id =”{!Idea_Lobby__c.Id}”;                  

idLob.Vote_Test__c ="Up" ; 

newRecords.push(idLob);            

result = sforce.connection.update(newRecords); 
window.location.reload();

Thanks for everyone's help!

You must log in to answer this question.

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