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
EnryEnry 

Javascript Button to run apex class

Hi,I want create a custom button that runs an apex class.

This class create a record and open the detailed page of the record created.

Do you know if is it possible?

Do you have an example code for the button that exercutes the class? javascript?

Thanks in advantage for any advice.

BR.

Marko LamotMarko Lamot
I assume you want to put button on standard layout.
 
Create VF:
 
<apex:page standardcontroller="yourobject" extensions=" yourcontroller" action="{!youraction}">
</apex:page> 
 
then create a custom button (type execeut VF page) and select above VF
EnryEnry

Now I'm thinking  to create visual force page with just a button and put it on my standard layout. Do you know also if in the controller of custom page with only the button i can get the id of the record from the url? i want get the id of the record on which i have the button.Thanks

Marko LamotMarko Lamot

yes you can, of course.