6 Replies Latest reply on Mar 22, 2014 2:20 AM by try67

    Are variables carried over from one function to the other?

    MatLac Level 3

      I have a mouseUp event in a button that performs a verification before triggering a submitMe() function I created.  During that verification, var aResult is defined.  Then, submitMe() triggers this.mailDoc with aResult in cBody.


      This works fine, thus showing that a variable defined in a mouseUp event is carried over to a function I created.


      Then I decided to move the verification to document-level as a function creating verifyMe() and triggering it with the same mouseUp event as before.


      But now, during submitMe(), console tells me aResult is not defiened.


      So the question is, does it change anything that submitMe() is now a function-inside-a-function and does it prevent aResult to carry over?


      function verifyMe()


      var aResult = aDefault.join("\n\t");

            if (aResult != ""){
                  var cResponse = app.alert(ermsg + "\t" + aResult + "\n\n" + "Dou you want to submit?")
                   if (cResponse == "4"){






      //Since the app.alert is triggered and shows the correct result, aResult is defined!!!!



      function submitMe()
      var Sub = this.getField("OPE028.1.EVEN.NO").value;
      var emailSij = "xxxx@xxxx";
      var emailMat = "xxxx@xxxxx";
      var cBody = "******test******\r\t"+aResult;


      this.mailDoc({ bUI: false, cTo: emailSij, bCc: emailMat, cSubject: Sub, cMsg: cBody });