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
dwickdwick 

Invoking a custom class with a button

Hi,

I have a custom apex class (which works properly when executed anonymously through the IDE) and would like to be able to invoke the class with the click of a button on a visual force page.  I have a feeling it's really simply, but i just can't seem to figure it out.

 

Here's what I have so far:

 

 

<apex:page >
<apex:enhancedList type="SPC_Settings__c" height="358" rowsPerPage="10" id="SPCSettings" />
<apex:form >
<br />
<apex:commandButton style="float:right;" action="sforce.apex.execute('SPCSettingsUpdate',{},{}" value="Update" id="btnUpdate" />
</apex:form>
</apex:page>

 

Any help would be greatly appreciated!

 

Best Answer chosen by Admin (Salesforce Developers) 
Ron HessRon Hess

 

my suggestion, but you will still need to make mods to get the controller to initialize and the action may need a parameter

 

<apex:page   controller="SPCSettingsUpdate" >
<apex:enhancedList type="SPC_Settings__c" height="358" rowsPerPage="10" id="SPCSettings" />
<apex:form >
<br />
<apex:commandButton style="float:right;" action="{!Update}" id="btnUpdate" />
</apex:form>
</apex:page>	

All Answers

Ron HessRon Hess

 

my suggestion, but you will still need to make mods to get the controller to initialize and the action may need a parameter

 

<apex:page   controller="SPCSettingsUpdate" >
<apex:enhancedList type="SPC_Settings__c" height="358" rowsPerPage="10" id="SPCSettings" />
<apex:form >
<br />
<apex:commandButton style="float:right;" action="{!Update}" id="btnUpdate" />
</apex:form>
</apex:page>	
This was selected as the best answer
dwickdwick

So in the above case is update just the name of a function within the class?

dwickdwick

Got it working, thanks Ron!