1

I've spent many hours scouring the net and trying different coding options to get a very simple function accomplished, with no luck.  There are no examples anywhere that I can find, and SF's documentation is typically unhelpful, hinting that the desired functionality is possible, but not enough information to implement.  Is there anybody out there that can help?

I have a continuation in my VF page.  I call its callout from a function started by a command button on the page.  The command button function returns a pagereference, and the callback function of the continuation returns a pagereference.  I want to get the pagereference returned by the continuation's callback and navigate to it.  Obviously, to do this I want to wait until the callback is finished - I think the code does that but I am not certain.

CallScheduler();
PageReference pageRef = 'Return value from callback, how do i get it?';
pageRef.setRedirect(true);
return pageRef;

Here are the declarations of the callout and callback continuation methods:

public Object CallScheduler() {
  Continuation con = new Continuation(30);
  con.continuationMethod = 'SchedulerCalled';
  HttpRequest req = new HttpRequest();
  ...

public PageReference SchedulerCalled() {
  ...
  return new PageReference('/' + myNewRecord.id);

For those who want to recommend a change to the design, the continuation inserts a custom object that includes fields retrieved from an external web service call. The fields are required. The code must get 75% test coverage, and must pass force.com security and quality scanning.

  • Recent discovery: Apex is not calling the callback method, even though the callout code assigns the callback method, successfully acquires a requestLabel, and reaches the point where it returns the continuation object. – aging hippie Feb 3 '17 at 20:17
  • what happens if you change public PageReference SchedulerCalled() { to public Object SchedulerCalled() { – NSjonas Feb 3 '17 at 21:02
  • Still doesn't call it. – aging hippie Feb 3 '17 at 22:02
  • My use case: Complete a form and submit. Once the data is submitted and edited, call an external system to update it and get back data, including the external system's unique identifier. Then create an sObject in SF that includes that external system's data. Then navigate to the id of the sObject you just stored. Maybe continuation isn't the right way to get this done - it seems buggy and poorly documented. But I don't know another technique that would apply. – aging hippie Feb 3 '17 at 22:53
  • how long does the callout take? – NSjonas Feb 3 '17 at 23:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.