You need to sign in to do that
Don't have an account?
anil.ax822
Triggering an Apex method with a Custom Button
Hi,
I have a custom button in account called 'submit' and it's a onclick Java script event when i click on the button it displays error
A problem with the OnClick JavaScript for this button or link was encountered:
{faultcode:'soapenv:Client', faultstring:'No operation available for request {http://soap.sforce.com/schemas/package/OutboundEmails}SendEmailNotification, please check the WSDL for the service.', }
iam using 21.0 version
JS code:
{!REQUIRESCRIPT("/soap/ajax/
21.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/21.0/apex.js")}
var AccId= '{!Account.Id}';
sforce.apex.execute("OutboundEmails","SendEmailNotification", {id:AccId});
window.alert("Account Id is sent." )
Apex code:
ERROR:sforce is not defined
{!REQUIRESCRIPT("/soap/ajax/21.0/apex.js")}
var AccId= '{!Account.Id}';
sforce.apex.execute("OutboundEmails","SendEmailNotification", {id:AccId});
window.alert("Account Id is sent." )
global class OutboundEmails { mail.setToAddresses(new string[] {'Myself@gmail.com'});WebService static void SendEmailNotification(Id id) { //create a mail object to send a single email. Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); //set the email properties mail.setSenderDisplayName('SF.com Email Agent'); mail.setSubject('A new reminder'); mail.setHtmlBody('an object with ID='+ id + ' is just clicked on.'); //send the email Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail } ); } } |
ERROR:sforce is not defined
I tried the same code in my org and its working for me.
Check the Version of your class also.
All Answers
I tried the same code in my org and its working for me.
Check the Version of your class also.
Yeh it works fine for me
Thanks Rahul