You need to sign in to do that
Don't have an account?
Raj R.
How to initiate a future class from VF page on button click?
Hi,
We have a VF page that has a button which is supposed to trigger some action. How would we create a button on the VF page that will call a future class once clicked?
The objective is to click the button, then initiate a future class to perform some action that will run in the background while the user is able to proceed.
We have a VF page that has a button which is supposed to trigger some action. How would we create a button on the VF page that will call a future class once clicked?
The objective is to click the button, then initiate a future class to perform some action that will run in the background while the user is able to proceed.
///Apex
public with sharing class ExampleController {
Public static string futureResult {get;set;}
/*Add the logic here or call any future method as needed */
@future
public static void callFutureMethod(){
futureResult='Future has been Called';
}
}
Vf
<apex:page controller="ExampleController">
<apex:form >
Future result: {!futureResult}<br/>
<apex:commandButton action="{!callFutureMethod}" reRender="" title="Click to Call Future" value="FutureCall"/>
</apex:form></apex:page>
This is working example and should work in your case as well.
You might have to use ActionPoller to check if the processng has been completed and if user should be notified about the background activity.
Please mark the answerif thsi solves your problem