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
Bryan PaldinoBryan Paldino 

Custom button "Unexpected Identifier" error

Hi,
I am tring to update a custom field on the opportunity object using a custom button.  I was able to create the button but I get an "Unexpected Identifier" error whenever the button is pressed.   I'm new to writing to JavaScipt code, so I'm having some trouble troubleshooting the error.


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

Var Opp = new sforce.SObject("Opportunity")
Opp.Id = '{!Opportunity.Id}'
Opp.Submit_to_UW__c = 'Yes'

var results = sforce.connection.update([Opp])
window.location.reload()


PavanKPavanK
Could you please try with older version for example

{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")} 
Bryan PaldinoBryan Paldino
Unfortunately I got the same error.

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

Var Opp = new sforce.SObject("Opportunity")
Opp.Id = '{!Opportunity.Id}'
Opp.Submit_to_UW__c = 'Yes'

var results = sforce.connection.update([Opp])
window.location.reload()
PavanKPavanK
Wierd :( . Because i have implemented similar functionality and its working. Can you please try below

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

Var Opp = new sforce.SObject("Opportunity");
Opp.Id = '{!Opportunity.Id}';
Opp.Submit_to_UW__c = 'Yes';

var results = sforce.connection.update([Opp]);
window.location.reload();
Bryan PaldinoBryan Paldino
Still no luck.   Does it matter that it's a picklist field?