You need to sign in to do that
Don't have an account?
LeeMurphy
Where am I missing a semicolon?
I have a custom button which is supposed to send an email, but I'm getting the following error when I click it:
"A problem with the OnClick JavaScript for this button or link was encountered: missing ; before statement"
My button executes the following OnClick Javascript:
{!REQUIRESCRIPT("/soap/ajax/23.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/23.0/apex.js")} Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); mail.setTargetObjectId({!Case.AccountId}); mail.setTemplateId('00XD0000001SLYh'); mail.setBccSender(false); mail.setToAddresses({!Case.SuppliedEmail}); Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); }
I can't see a missing semicolon?
Someone please shed some light on this for me as I can't move forward until this is resolved.
Hi Lee,
As such we cannot use apex methods directly in AJAX.
We need to write a separate apex class and then it need to invoked in the AJAX using the below AJAX method,
sforce.apex.execute("ApexClassName", "webServiceMethod", {param1,param2..,paramn})
ApexClassName - should be the name of your class which sends mail.
webServiceMethod - is the method in that class
param1,param2..,paramn - are the parameters passed onto the method
Please refer to my blog post on Sending Email Alerts via AJAX, to get a detailed idea on procedure.
Let me know if you face any issues still.
I believe that my blog post solves your issue, mark this post as solved for the benefit of others.
Regards,
Bharathi
Salesforce For All