How to open a VF page from future callout method?

I am working on requirement , i will make a callout to external system to get the lead details , before i insert the lead details i need to display it in VF page for confirmation?

  • What should happens if lead inserted using data loader?
    – kurunve
    Jun 29, 2017 at 14:41
  • This question is marginally better than your last one on the same topic. You've included some details about what you're looking for, but at first glance it still sounds like a nonsensical request. Generally speaking, the more details you can provide, the better the quality of answer that you'll receive.
    – Derek F
    Jun 29, 2017 at 15:17

2 Answers 2


What you are looking for is not possible to open a page from the async call. You may do the following.

1) Implement VF page for edit and insert and do web service call.

2) Do a future call and update record asynchronously

3) if it is long running call use this


This question is very close to being an XY-problem (that is, you have a problem X, and you've chosen a solution Y. You're asking about how to make your solution Y work instead of asking how to solve problem X).

@future is not the right tool for the job here, at least not for the problem as worded in your question. @future is meant to be fire-and-forget. @future returns no data, and provides no indication of when it has finished. You could try to query the AsyncApexJob object (which will contain very limited information about the @future call), but trust me when I say that's not a road you want to go down.

Instead, the feature you're looking for is called apex continuations. The key feature that makes continuations suited for this task is that a continuation allows you to specify a callback method that is executed when your callout finishes (and that callback method can cause a page refresh to display the returned data).

Beyond that, another option I could suggest is to abandon trying to display data to the user before inserting records into Salesforce. Instead, you could simply insert records using data from your callout (a task for which @future is well suited) and use a picklist field, or different record types to distinguish between records that need to be reviewed and those that have been reviewed. You would likely need to prompt your users to review records from time to time, but making a listview to show which records need review (based on either a picklist field or a record type) is quick and simple.

  • Thanks for the detailed information, i will try to implement the whole functinality using apex continuations ... but my doubt here actually i need to call 3 callouts. when the fisrt callout is finished immediatly i need to invoke the second callout once the second one finishes later i need to invoke the third callout, this scenorio can be possibke via apex continuation?
    – Mahesh
    Jun 30, 2017 at 7:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .