8 Replies Latest reply: Mar 29, 2012 12:39 PM by DKinsley RSS

    Verify e-mail address field is not null.

    DKinsley Community Member

      I am trying to get the script below to verify the "ReleasedIntoSystemBy" field (drop-down with email address values) is not blank. What have I got wrong?

       

       

      // Declare the variable
      var vEmail;
      var vSubject = "New Work Order/Project Authorization"
      var vBody = "Instructions:"

      // Check that the email field is not null
      if (xfa.resolveNode("#subform[0].#subform[2].Table111[1].Row1.ReleasedIntoSystemBy").rawValu e !== null) {
           vEmail = xfa.resolveNode("#subform[0].#subform[2].Table111[1].Row1.ReleasedIntoSystemBy").rawValue ;
      }

      // Send email
      event.target.submitForm({cURL:"mailto: " + vEmail + "?subject=" + vSubject + "&body=" + vBody,cSubmitAs:"PDF",cCharset:"utf-8"});

        • 1. Re: Verify e-mail address field is not null.
          Jenn Andrews Community Member

          The script looks correct however, you are doing //Send Email script whether or not the vEmail value is null as it lies outside the if statement

           

          I''m assuming you want to send if vEmail is not null.  If that is the case then place the //Send Email script within the if statement.

          • 2. Re: Verify e-mail address field is not null.
            DKinsley Community Member

            Yes - you are correct. I did as you suggested and changed it as seen below. Now it does nothing when blank. Is it possible to generate a message telling the user they left that field blank?

             

             

            // Declare the variable
            var vEmail;
            var vSubject = "New Work Order/Project Authorization"
            var vBody = "Instructions:"

            // Check that the email field is not null
            if (xfa.resolveNode("#subform[0].#subform[2].Table111[1].Row1.ReleasedIntoSystemBy").rawValu e !== null) {
                 vEmail = xfa.resolveNode("#subform[0].#subform[2].Table111[1].Row1.ReleasedIntoSystemBy").rawValue ;
                 // Send email
            event.target.submitForm({cURL:"mailto: " + vEmail + "?subject=" + vSubject + "&body=" + vBody,cSubmitAs:"PDF",cCharset:"utf-8"});
            }

            • 3. Re: Verify e-mail address field is not null.
              Jenn Andrews Community Member

              Here you go

               


              // Declare the variable
              var vEmail;
              var vSubject = "New Work Order/Project Authorization"
              var vBody = "Instructions:"

              // Check that the email field is not null
              if (xfa.resolveNode("#subform[0].#subform[2].Table111[1].Row1.ReleasedIn toSystemBy").rawValue !== null) {
                   vEmail = xfa.resolveNode("#subform[0].#subform[2].Table111[1].Row1.ReleasedInt oSystemBy").rawValue;
                   // Send email
              event.target.submitForm({cURL:"mailto: " + vEmail + "?subject=" + vSubject + "&body=" + vBody,cSubmitAs:"PDF",cCharset:"utf-8"});
              }else{
              //displays message box warning user to fill in field

              xfa.host.messageBox("Please fill the email field");

              //sets the focus to the field
              xfa.host.setFocus(xfa.resolveNode("#subform[0].#subform[2].Table111[1].Row1.ReleasedIntoS ystemBy"));

              }

              • 4. Re: Verify e-mail address field is not null.
                DKinsley Community Member

                Thank you so much!

                 

                -Don

                • 5. Re: Verify e-mail address field is not null.
                  DKinsley Community Member

                  Is there a way to have the required fields verfied that they are populated before the custom email button executes?

                   

                  Thanks again for your help!

                  • 6. Re: Verify e-mail address field is not null.
                    Jenn Andrews Community Member

                    if you execute the below script it will check all validations on the form such as required fields

                     

                    xfa.form.form1.execValidate()   

                     

                    form1 being the top node of you hierarchy

                     

                    it will return a true or false, true if validatations are all fullfilled or false if not

                    In your script you could add an if statement similar to this

                     

                     

                    if(xfa.form.form1.execValidate() == true){

                      //within here execute your above email script

                    }

                     

                     

                    • 7. Re: Verify e-mail address field is not null.
                      DKinsley Community Member

                      Having trouble - is this correct?

                       

                      var vEmail;
                      var vSubject = "New Work Order/Project Authorization"
                      var vBody = "Instructions:"

                      if(xfa.form.form1.execValidate() == true){

                      // Check that the email field is not null
                      if (xfa.resolveNode("#subform[0].#subform[2].Table111[1].Row1.ReleasedIntoSystemBy").rawValu e !== null) {
                           vEmail = xfa.resolveNode("#subform[0].#subform[2].Table111[1].Row1.ReleasedIntoSystemBy").rawValue ;
                      }

                      // Send email
                      event.target.submitForm({cURL:"mailto: " + vEmail + "?subject=" + vSubject + "&body=" + vBody,cSubmitAs:"PDF",cCharset:"utf-8"});
                      }

                      • 8. Re: Verify e-mail address field is not null.
                        DKinsley Community Member

                        I got it working - thanks again!