function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Custom Button Using Apex

Hi Everybody,

I want a custom button(next to: Request Update in contact page). 

When the button is pressed(by the admin) it should send mail to particular person(Let the contact person name be : XX)

XX receives a mail and XX should fill the custom fields sent along with the mail (this is to update the contact info).

When XX fill up the fields and hits the submit button it should be updated in Admin DB.

Is it possible?





Hi Hasan,


I would really question your use case, but here's how you can invoke APEX from a Cutom Button:


First, create an Apex Class with at least one method:



global class MySuperCoolClass{
Webservice static void DoThis(String objectId) {
// Here goes your logic



And this is what you put in your Button of type "Execute Javascript":






Good Luck and have fun :)




As an FYI, there is another option for invoking Apex code from a custom button. Create a new VF page and an associated custom controller. Bind the 'action' attibute of the top level <apex:page> tag to a method in the custom controller. Include the custom Apex logic that you want performed in this method. You can now associate the new custom button with the VF page and your custom Apex logic will be triggered when the user clicks on the button.

Hope this helps.