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

Open Visualforce Page through @future method


I have a @future method Display().
I want to open visualforce page after executing callout code from future method.

public static void display()
//callout code
//after this callout code, this method should open vf page

I am calling this future method thro' after insert trigger.
Shaijan ThomasShaijan Thomas
<apex:outputPanel id="tstpopup">
            <apex:outputPanel styleClass="popupBackground" layout="block" rendered="{!displayPopUp}"/>
            <apex:outputPanel styleClass="custPopup" layout="block" rendered="{!displayPopUp}">
             <apex:actionStatus id="loadingFilter">
            <apex:facet name="start">
                <img src="{!$Resource.AjaxAnimation}" />
                <FONT COLOR="black" SIZE="2"><b><i>Processing....</i></b></FONT>
                       <apex:outputPanel style="height:200px;overflow:auto;" id="inpanel" layout="block">
                       //put your code here
		//displayPopUp value set true or false in your code

try somthing like this
Gil GourévitchGil Gourévitch
This seems not to be possible :
when you call a future method, there is no return (void return type), and the navigator is not the client, the method is executed "when Salesforce has available resources" see SF doc about future anotation here (
So the platform executing the @future method cannot know who to send the response, and so the redirection.

Hope this helps

Question Solved ? Please mark as the best answer to help other users !
Hi Gil,

What should I do then.
Actually my scenario is, whenever callout fails it should display some custom error message on visualforce page

Gil GourévitchGil Gourévitch
I think you have to change the type of your Display method, and not calling it from a trigger.
If the you are in a VF page with a controller, you can make the callout directly into the controller, and display the message (you are in a controller context, so your browser is the client) in VF page with <apex:messages /> tag.
Then you save the record only if the callout is successfull.

Hope this helps

Question Solved ? Please mark as the best answer to help other users !