5 Replies Latest reply on Mar 21, 2011 10:38 AM by philmodjunk

    case statement using IsEmpty, question

    kilbot

      Title

      case statement using IsEmpty, question

      Post

      I have 2 fields and I want to write a case statement to the following effects:

      I both fields are empty to do nothing,

      if both contain text give error message

      and if one is empty and the other has text get the one that has text.

      So I thought I would need to write a case statement for this but got lost when I had to think if 1 had text. Is there a way to make a Not IsEmpty calculation:

      Case(IsEmpty(field1) and IsEmpty(field2);"";

      Then I got stuck

      Thanks

        • 1. Re: case statement using IsEmpty, question
          philmodjunk

          You're on the right track, that's the first boolean expression you'll need.

          Case(IsEmpty(field1) and IsEmpty(field2);"";
                  IsEmpty ( field1 ) ; field2 ;
                  IsEmpty ( field2 ) ; field 1 ;
                  "error message here"
                  )

          This assumes you want the error message to be returned by the calculation. If you wan't to pop it up in a dialog box, other means are required.

          • 2. Re: case statement using IsEmpty, question
            kilbot

            Can you have it pop up in a dialog box on a calculation? I know you can on a script. How do you make it occure on calculations.

            By the way thanks

            • 3. Re: case statement using IsEmpty, question
              philmodjunk

              Take out the "error message here" clause from the calculation.

              Define a separate validation rule that displays a custom validation message when both fields contain a value. You can set this rule on either one of the two fields, (no need for both), to get the error pop up.

              IsEmpty ( field1 ) or IsEmpty ( field2 )

              • 4. Re: case statement using IsEmpty, question
                kilbot

                Okay

                I made a script I was going to set for validation but doesn't seem to work. I think I did something wrong

                Set error capture [on]

                if [IsEmpty(Field1) or IsEmpty(Field2)]

                show custom dialog

                end if

                • 5. Re: case statement using IsEmpty, question
                  philmodjunk

                  That's not what I meant. You didn't want a script, so I described a method that does not use a script.

                  Open Manage | Database | Fields and double click the field definition for either field1 or field2.

                  Click Validation

                  Select the calculation option and enter:

                  IsEmpty(Field1) or IsEmpty(Field2) //(This expression is True if either field is empty)

                  Enter whatever error message you want in the Custom Validation message box at the bottom of this dialog.

                  If you want to script it, you have to reverse the logic to identify invalid values here:

                  Not ( IsEmpty(Field1) or IsEmpty(Field2 )