You need to sign in to do that
Don't have an account?
louisa barrett 7
OnClick javaScript button error
Could someone let me know what's wrong with the below code.
It was all working fine until I introduced the IF statement, which should be a simple thing.
I'm now getting errors ranging from IF is not defined to Missing ) after arguments.
I'm must be missing something obvious.....
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
// single mail request
(function() {
var mail = new sforce.SingleEmailMessage();
var templatedId = "00Xb0000000ZiYS";
var contactId = "";
{IF({!Opportunity.Branch__c } == "Birmingham Opportunity",
contactId = "0037E00000GpjxR",
contactId = "0037E00000GpjeO")}
opportunityId = "{!Opportunity.Id}";
mail.replyTo = "{!$User.Email}";
mail.targetObjectId= (contactId);
mail.whatId= (opportunityId);
mail.templateId = (templatedId);
var result = sforce.connection.sendEmail([mail]);
if(result[0].success == 'true') {
alert("Your email has been sent.");
} else {
alert("I had a booboo.");
}
}());
It was all working fine until I introduced the IF statement, which should be a simple thing.
I'm now getting errors ranging from IF is not defined to Missing ) after arguments.
I'm must be missing something obvious.....
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
// single mail request
(function() {
var mail = new sforce.SingleEmailMessage();
var templatedId = "00Xb0000000ZiYS";
var contactId = "";
{IF({!Opportunity.Branch__c } == "Birmingham Opportunity",
contactId = "0037E00000GpjxR",
contactId = "0037E00000GpjeO")}
opportunityId = "{!Opportunity.Id}";
mail.replyTo = "{!$User.Email}";
mail.targetObjectId= (contactId);
mail.whatId= (opportunityId);
mail.templateId = (templatedId);
var result = sforce.connection.sendEmail([mail]);
if(result[0].success == 'true') {
alert("Your email has been sent.");
} else {
alert("I had a booboo.");
}
}());
use below code
Hopw it will work
Mark Best ANSWER if its work for you.
Thanks
karthik
All Answers
use below code
Hopw it will work
Mark Best ANSWER if its work for you.
Thanks
karthik
I am trying to write a simple JS button on opportunity to toggle a picklist based on its existing value. When I run it I get an error.
Check whether Sync Flag not set to 'Sync' and update it to 'To Be Sync'. Not sure why I am getting this error. Please help! Thanks!!
Button: Error: