+ Start a Discussion
Doug BurkhartDoug Burkhart 

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:

var opportunity = new sforce.SObject("Opportunity"); 
opportunity.id = "{!Opportunity.Id}"; 
oppportunity.Email_Deal_Summary__c = "True"; 

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?
Baktash HossainzadehBaktash Hossainzadeh

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

Doug BurkhartDoug Burkhart

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).
Baktash HossainzadehBaktash Hossainzadeh
try true instead of "true"
Doug BurkhartDoug Burkhart
I've made the change but it is still not updating the field.
Baktash HossainzadehBaktash Hossainzadeh
try this:
var result = sforce.connection.update([opportunity]);
Doug BurkhartDoug Burkhart
That worked!! Thank you! I ddid remove the alert though as I would prefer the users to not get the pop-up.