5 Replies Latest reply on Sep 15, 2016 2:24 PM by fmpdude

    Pls help - what is wrong with this validation criteria

    jb@mps

      I am trying to evaluate the value of a field named "Printers" to be valid if "Printers" field is not empty or if value of another field named "Output" is set to "PDF". But following validation criteria is not working:

       

      not ( IsEmpty ( Printers ) )

      or

      Exact ( GetField(TradeShowVDP::Output) ; "PDF" )

       

      Thanks!

        • 1. Re: Pls help - what is wrong with this validation criteria
          philmodjunk

          IsEmpty ( Printers )

          or

          Exact ( TradeShowVDP::Output ; "PDF" )

           

          You indicated that the record is valid if the field IS empty, so "Not" makes no sense here.

           

          I am assuming that you want to check that TradeShowVDP::Output has the text "PDF" and that it's all uppercase (don't see why you'd care about case, but that's what "Exact" does in this expression.)

           

          GetField returns the value of the field named inside the parenthesis, so unless TradeShowVDP::Output stores text such as: "SomeTable::SomeField" and you want the value of SOmeTable::SomeField, it doesn't make sense to use it here.

          • 2. Re: Pls help - what is wrong with this validation criteria
            jb@mps

            Sorry for any confusion because I am very new at all of this. I would like the "Printers" field value to be valid in the following two cases:

            1) There is a value; the "Printer" field is Not Empty.

            OR

            2) The "Printer" field is empty and "PDF" is the value of the "Output" field.

            • 3. Re: Pls help - what is wrong with this validation criteria
              fmpdude

              The best way to figure this out is to FIRST create a truth table. It can be quite difficult to get complicated logical conditions correct by just swinging at them in code.

               

              Pseudo code is another way to figure this out ... IOW, don't try to get the "FM" syntax right, just look at your logic.

               

              NOT (ISEMPTY(PRINTER_FIELD) OR ( (ISEMPTY(PRINTER_FIELD) AND OUTPUT_FIELD = "PDF") )

               

              (Once the expression looks right and passes your tests, then change the pseudo code above into real FM logic.)

               

              ------

               

              If you have FMPA, you can experiment with the data viewer too.

               

              HOPE THIS HELPS.

              1 of 1 people found this helpful
              • 4. Re: Pls help - what is wrong with this validation criteria
                jb@mps

                Got it working! Thank you so much! FYI: There was one other change that I needed to make. The "Validate only if field has been modified" option on the "Specify Validation for "Printers"" dialog was selected. That is what was preventing the validation from occurring when I modified the value for the "Output" field or applied any other action to the current record.

                • 5. Re: Pls help - what is wrong with this validation criteria
                  fmpdude

                  Excellent, good job! Glad it's working for you now.