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
JSpenceJSpence 

Call Custom Button Onclick event

Hello fellow SFdevs,

 

Is there a way to call the onclick event code in a custom button via apex from the system log?

 

Example:

 

MyObject.MyCustomSubmitButton()

 

 

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

Yes, you can instantiate an apex class and call methods on it - I use that mechanism to apply datafixes from time to time.

All Answers

bob_buzzardbob_buzzard

You won't be able to do that from apex I'm afraid. The custom button side of things is only available via the metadata api.

 

Can you explain a bit more about what the button does and what you are trying to achieve?

JSpenceJSpence

The button does some checks on the object to make sure it is in the right state then calls an enormous apex class with sforce.apex.execute(...). Can you call apex classes through the systemlog?

bob_buzzardbob_buzzard

Yes, you can instantiate an apex class and call methods on it - I use that mechanism to apply datafixes from time to time.

This was selected as the best answer