I am trying to create a flow which creates an account record and then navigates to the newly created record detail page

VF Code

<apex:page Controller="AccFlowController" TabStyle="Account">
<flow:interview name="CreateAccount" interview="{!myflow}" finishlocation="{!AID}" />

Apex Class code

 public class AccFlowController{

 public Flow.Interview.Quick_Account myFlow { get; set; }

 public String getmyID() {
 if (myFlow==null) return '';
  else return myFlow.accountId;

 public PageReference getOID(){
 PageReference p = new PageReference('https://dev-dev ed.my.salesforce.com/'+getmyID());
 return p;


However, when I try to save the class it is showing

Error: Compile Error: Variable does not exist: accountId

My flow has the following variable present

enter image description here

1 Answer 1


According to the documentation on Getting Flow Variables, you should call myFlow.getVariableValue:

String accountId = (String)myFlow.getVariableValue('accountId');
  • I tried it as well. But (String)myFlow.getVariableValue('accountId'); just fetches null even though the record is successfully created. @AdrianLarson
    – Madhurima
    Dec 6, 2018 at 20:42
  • That seems like a problem with your flow, not your Apex. This answer resolves what you were doing wrong in the code you posted.
    – Adrian Larson
    Dec 6, 2018 at 20:49
  • 1
    You were right. There was an issue with my flow. All I needed was a finish screen
    – Madhurima
    Dec 6, 2018 at 21:07

You must log in to answer this question.

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