Not being able to access Flow variable in Apex class





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty{ margin-bottom:0;
}






up vote
3
down vote

favorite












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






























    up vote
    3
    down vote

    favorite












    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


























      up vote
      3
      down vote

      favorite









      up vote
      3
      down vote

      favorite











      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 5 hours ago









      Adrian Larson

      103k19111233




      103k19111233










      asked 6 hours ago









      user55791

      221111




      221111






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          5
          down vote



          accepted










          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
            5 hours ago












          • 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
            5 hours ago






          • 1




            You were right. There was an issue with my flow. All I needed was a finish screen
            – user55791
            5 hours ago











          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',
          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








          up vote
          5
          down vote



          accepted










          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
            5 hours ago












          • 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
            5 hours ago






          • 1




            You were right. There was an issue with my flow. All I needed was a finish screen
            – user55791
            5 hours ago















          up vote
          5
          down vote



          accepted










          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
            5 hours ago












          • 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
            5 hours ago






          • 1




            You were right. There was an issue with my flow. All I needed was a finish screen
            – user55791
            5 hours ago













          up vote
          5
          down vote



          accepted







          up vote
          5
          down vote



          accepted






          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 6 hours ago









          Adrian Larson

          103k19111233




          103k19111233












          • I tried it as well. But (String)myFlow.getVariableValue('accountId'); just fetches null even though the record is successfully created. @AdrianLarson
            – user55791
            5 hours ago












          • 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
            5 hours ago






          • 1




            You were right. There was an issue with my flow. All I needed was a finish screen
            – user55791
            5 hours ago


















          • I tried it as well. But (String)myFlow.getVariableValue('accountId'); just fetches null even though the record is successfully created. @AdrianLarson
            – user55791
            5 hours ago












          • 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
            5 hours ago






          • 1




            You were right. There was an issue with my flow. All I needed was a finish screen
            – user55791
            5 hours ago
















          I tried it as well. But (String)myFlow.getVariableValue('accountId'); just fetches null even though the record is successfully created. @AdrianLarson
          – user55791
          5 hours ago






          I tried it as well. But (String)myFlow.getVariableValue('accountId'); just fetches null even though the record is successfully created. @AdrianLarson
          – user55791
          5 hours ago














          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
          5 hours ago




          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
          5 hours ago




          1




          1




          You were right. There was an issue with my flow. All I needed was a finish screen
          – user55791
          5 hours ago




          You were right. There was an issue with my flow. All I needed was a finish screen
          – user55791
          5 hours ago


















          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

          How did Captain America manage to do this?

          迪纳利

          南乌拉尔铁路局