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
DarrellDDarrellD 

Flow variables not passing back to VF Controller Extension

For some reason my variables from my Flow are passing back as null to my VF Controller extension.  Trying to set the finish page using these. Was able to understand how in another post (Rajaram).

 

Controller extension is below.  The vafacilityid is an Input/Output variable in Flow FacilityLookup and should return the Account ID newly created. In the flow I added a screen that validates that the variable does have a value at the end of the flow so something is wrong with the controller?

 

Controller Extension

public class flowFinishContExt_Acct {

private final Account acct;

public flowFinishContExt_Acct(ApexPages.StandardController stdController) {
this.acct = (Account)stdController.getRecord();
}

public Flow.Interview.FacilityLookup atFlow {get; set;}

public String getaccountID() {
if (atFlow==null) return '';
else return atFlow.vafacilityid;
}

public PageReference getFinishPage(){
PageReference p = new PageReference(''/apex/FacilityMainTabbed' + getaccountId());
p.setRedirect(true);
return p;
}

}

Best Answer chosen by Admin (Salesforce Developers) 
DarrellDDarrellD

This seems like a little bug to me.  I'll also post to the Flow people.

 

There was nothing wrong with the code below.  When I looked at log files, the variable value was null from the Flow.  But if I add a screen to check the value of the variable inside the Flow, it was populating.  SO, I tried keeping that screen in place when running the Flow and...voila it worked!

 

So what this means is that if the Flow essentially ends on a Record Create statement (I also had a decision after this and that was still a problem), then the variable doesn't get passed back and is null.  Don't ask me why, but I've now added a confirmation screen for the user as the last step and all works fine.

All Answers

DarrellDDarrellD

This seems like a little bug to me.  I'll also post to the Flow people.

 

There was nothing wrong with the code below.  When I looked at log files, the variable value was null from the Flow.  But if I add a screen to check the value of the variable inside the Flow, it was populating.  SO, I tried keeping that screen in place when running the Flow and...voila it worked!

 

So what this means is that if the Flow essentially ends on a Record Create statement (I also had a decision after this and that was still a problem), then the variable doesn't get passed back and is null.  Don't ask me why, but I've now added a confirmation screen for the user as the last step and all works fine.

This was selected as the best answer
MTBeitlerMTBeitler

I've run into the same issue.  I have a multi-screen flow and the flow variables that have default values that are pulled from the last screen of the flow do not get set.  

 

If I kludge it and add a "dummy" screen after my real last streen, those flow variables are then set correctly.

 

Matt Beitler
Chatham Financial

 

ManzaManza
Thanks MTBeitler I have spent a couple of hours until I try your solution and it works.Such a weird bug
Ian Carswell 13Ian Carswell 13
This is still a problem. Is there a bug number or some other way to track this? When will this be fixed?
DarrellDDarrellD
This was a few years ago. This works now. I haven't updated this in a long time so can't exactly tell you how but look around either here or Success Community as I know you can do this now.