You need to sign in to do that
Don't have an account?

Custom Button error using javascript
I am trying to create a custom button on Opportunities. I have named he Button "Email Deal Summary". When clicked, I would like the button to update the checkbox field "Email_Deal_Summary_c" to be True. I have used the following javascipt:
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
var opportunity = new sforce.SObject("Opportunity");
opportunity.id = "{!Opportunity.Id}";
oppportunity.Email_Deal_Summary__c = "True";
sforce.connection.update([opportunity]);
window.location.reload();
Each time I click the button then, I am receiving the error "opportunity is not defined". I am fairly new to creating buttons using javascript. What am I doing wrong?
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
var opportunity = new sforce.SObject("Opportunity");
opportunity.id = "{!Opportunity.Id}";
oppportunity.Email_Deal_Summary__c = "True";
sforce.connection.update([opportunity]);
window.location.reload();
Each time I click the button then, I am receiving the error "opportunity is not defined". I am fairly new to creating buttons using javascript. What am I doing wrong?
Hello Doug,
did you copy and paste the code from your button?
There is a little mistake. In this line you wrote opportunity with 3 p's.
oppportunity.Email_Deal_Summary__c = "True";
Can you fix it and try again?
Best regards,
Baktash Hossainzadeh
Thanks for the quick reply. I thought I triple checked for spelling. I did make this change and I am no longer getting the error. However, it is not actually updating my field (Email_Deal_Summary__c) to be true (checked).
var result = sforce.connection.update([opportunity]);
alert(result);