2 Replies Latest reply on Jul 30, 2014 2:15 AM by Victoria Agafonova

    Is is possible to validate a form in a workflow?

    Victoria Agafonova Level 1

      I have  an .xdp form and .xml file with some data. Using renderPDFForm2 Operation I convert these two files into the pdf document. All this happans in a workflow/process, which is used by some external system. And after convertation a system receives the result pdf document.

      So, the question: is it possible to validate pdf document in a workflow? For example, my validation script in a form contains some code for checking if a client age is above 18 y.o. So, if the input data contains client age = 17, i want to return to the system some sort of error, but not the resulting pdf.

      An ideal solution which i want to find is some way to validate pdf form without dublicating validation code. Cause i have an idea how to check the age, using variables and expresions in a process. But in that case i'll have this validation both in pdf document (for example, to prevent users from printing not valid pdfs) and in a workflow.

        • 1. Re: Is is possible to validate a form in a workflow?
          Magus069 Level 4

          Hi Victoria,

           

          I have a validation script for PDF forms, you can use this script to validate the whole form to verify if any field returns null. This script is only to check if all fields are filled in. There is an exception array which you can insert field's names which you don't want it to be validated. You can then make your own validation for those fields included in the exception array.

           

          So as an example, if your field age is named : txtAge

          you would insert the name txtAge in the exception array:

          var tabException = new Array("txtAge", "txtAnyOtherField");

           

          var strFirstField = objValidate.getFirstField(form1, tabException);//form1 to be the top most subform or any subform to validate

           

          var boValidate = true;

          if (strFirstField != ""){

               boValidate = false;

          }

           

          if (boValidate){

               if (parseInt(txtAge.rawValue) < 18){

                    boValidate = false;

                    strFirstField = txtAge.somExpression;

               }

               if (boValidate){

                    //Any specific validation to be put here before printing

               }

          }

           

           

          if (!boValidate){

               xfa.host.setFocus(strFirstField);

               xfa.host.messageBox("Error, please make sure data is valid.");

          } else{

              xfa.host.print(1, "0", (xfa.host.numPages -1).toString(), 0, 0, 0, 0, 0);

          }

           

           

           

          You can use this template form to see how the function works:

          Validation / Reset Functions, easy to manipulate and to change Forms!!!!

           

          Hope this helps.

          • 2. Re: Is is possible to validate a form in a workflow?
            Victoria Agafonova Level 1

            Thank you a lot for your answer, Magus069. But i can't get it, how can this help me? The script you've provided is just a validation script. It'll work in case i'll use my form in Acrobat Reader, trying to print it, or press Submit button. But the thing i want is to validate the form in  a workflow, during the proccess.