Not being able to access Flow variable in Apex class












3














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">
<br/>
<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());
p.setRedirect(true);
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










share|improve this question





























    3














    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">
    <br/>
    <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());
    p.setRedirect(true);
    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










    share|improve this question



























      3












      3








      3







      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">
      <br/>
      <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());
      p.setRedirect(true);
      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










      share|improve this question















      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">
      <br/>
      <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());
      p.setRedirect(true);
      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







      apex visual-workflow compile-error visual-flows






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 6 at 20:49









      Adrian Larson

      104k19112235




      104k19112235










      asked Dec 6 at 19:50









      user55791

      2311111




      2311111






















          1 Answer
          1






          active

          oldest

          votes


















          5














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



          String accountId = (String)myFlow.getVariableValue('accountId');





          share|improve this answer





















          • I tried it as well. But (String)myFlow.getVariableValue('accountId'); just fetches null even though the record is successfully created. @AdrianLarson
            – user55791
            Dec 6 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 at 20:49






          • 1




            You were right. There was an issue with my flow. All I needed was a finish screen
            – user55791
            Dec 6 at 21:07











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "459"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f241709%2fnot-being-able-to-access-flow-variable-in-apex-class%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          5














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



          String accountId = (String)myFlow.getVariableValue('accountId');





          share|improve this answer





















          • I tried it as well. But (String)myFlow.getVariableValue('accountId'); just fetches null even though the record is successfully created. @AdrianLarson
            – user55791
            Dec 6 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 at 20:49






          • 1




            You were right. There was an issue with my flow. All I needed was a finish screen
            – user55791
            Dec 6 at 21:07
















          5














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



          String accountId = (String)myFlow.getVariableValue('accountId');





          share|improve this answer





















          • I tried it as well. But (String)myFlow.getVariableValue('accountId'); just fetches null even though the record is successfully created. @AdrianLarson
            – user55791
            Dec 6 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 at 20:49






          • 1




            You were right. There was an issue with my flow. All I needed was a finish screen
            – user55791
            Dec 6 at 21:07














          5












          5








          5






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



          String accountId = (String)myFlow.getVariableValue('accountId');





          share|improve this answer












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



          String accountId = (String)myFlow.getVariableValue('accountId');






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 6 at 20:32









          Adrian Larson

          104k19112235




          104k19112235












          • I tried it as well. But (String)myFlow.getVariableValue('accountId'); just fetches null even though the record is successfully created. @AdrianLarson
            – user55791
            Dec 6 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 at 20:49






          • 1




            You were right. There was an issue with my flow. All I needed was a finish screen
            – user55791
            Dec 6 at 21:07


















          • I tried it as well. But (String)myFlow.getVariableValue('accountId'); just fetches null even though the record is successfully created. @AdrianLarson
            – user55791
            Dec 6 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 at 20:49






          • 1




            You were right. There was an issue with my flow. All I needed was a finish screen
            – user55791
            Dec 6 at 21:07
















          I tried it as well. But (String)myFlow.getVariableValue('accountId'); just fetches null even though the record is successfully created. @AdrianLarson
          – user55791
          Dec 6 at 20:42






          I tried it as well. But (String)myFlow.getVariableValue('accountId'); just fetches null even though the record is successfully created. @AdrianLarson
          – user55791
          Dec 6 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 at 20:49




          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 at 20:49




          1




          1




          You were right. There was an issue with my flow. All I needed was a finish screen
          – user55791
          Dec 6 at 21:07




          You were right. There was an issue with my flow. All I needed was a finish screen
          – user55791
          Dec 6 at 21:07


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Salesforce Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f241709%2fnot-being-able-to-access-flow-variable-in-apex-class%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Plaza Victoria

          Puebla de Zaragoza

          Musa