1

I have class from which is used to send email. Currently i have a VF page and the class as controller. And a button on the standard layout of the custom object. When i click on the custom button send email it redirect me to VF page and from where i am sending email. But i want to send email by clicking on the send email button on the standard with out redirecting to the VF page. How can i achieve it. Please guide me if anybody have any idea.

3

Yes you can achieve this by below steps

step 1) Create a button on standard button and button Behavior should be Execute JavaScript.

  A) In this button you have to write javascript and remember include below files
    1) {!REQUIRESCRIPT("/soap/ajax/16.0/connection.js")} 
    2) {!REQUIRESCRIPT("/soap/ajax/16.0/apex.js")} 

step 2) You have to write a globle class in which you have to define a webservice method. Call this webservice method from button.

Now you need info, how we can call a method from javascript, so below links help you http://www.infallibletechie.com/2012/10/calling-apex-method-from-custom-buttom.html http://salesforcesource.blogspot.in/2009/06/triggering-apex-method-with-custom.html

one more link with similar question Best practice for calling Apex methods from custom button?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.