Edit CHECK to make sure that data exists only in one field

kristiakkristiak Posts: 1,249 ✭✭✭
I have two variables that should not be entered if two other variables exist. I.e if B and C exist than D and E must be empty, or vis versa if D and E exist than B and C must be empty! I have tried using show and hide and that works fine until you go back and change one of the pairs without deleting the two other. An edit check that would not allow this would be welcome! I can easily check that after the fact but it is a common error so I would prefer preventing it during data entry:
Anyone with an idea???
Tagged:
«13

Comments

  • ebsebs Posts: 111 ✭✭
    edited July 3
    We use rules to handle that.

    An empty field can be checked using FIELD_NAME eq ""

    A populated field can be checked using FIELD_NAME ne ""

    So to check that Field D is populated when it shouldn't be:

    FIELDB ne "" and FIELDC ne "" and FIELDD ne ""

    Then another rule for Field E

    FIELDB ne "" and FIELDC ne "" and FIELDE ne ""

    and so on to cover the various scenarios

    Cheers
    Eric
  • kristiakkristiak Posts: 1,249 ✭✭✭
    That looks smart. Can you use this syntax in e the validation columns so it fires immediately when you save the data or is that's where you handle the rule?
  • ebsebs Posts: 111 ✭✭
    The syntax is used in the rule expression field in rules designer. We use a Discrepancy Note action so that the user is shown an alert on saving the data and given a chance to correct it.
  • kristiakkristiak Posts: 1,249 ✭✭✭
    via Email
    Thanks Eric, I will try that!

    Best regards

    Krister
  • kristiakkristiak Posts: 1,249 ✭✭✭
    Sorry Erik could you please send me an example how this rule would be designed.

    Regards

    Krister
  • ebsebs Posts: 111 ✭✭
    edited July 26
    See attached file for a screenshot of the test page of Rules Designer.

    That rule will fire if FIELDB, FIELDC and FIELDD are all populated i.e. FIELDD should be blank but there is a value in it.

    You would then have to cover the other scenarios like FIELDE being populated at the same time as FIELDB and FIELDC




    In the CRF the user is prompted that Field D should be empty...




    Hope this is useful.

    Cheers
    Eric
  • kristiakkristiak Posts: 1,249 ✭✭✭
    Thanks Eric, I have never used the rules designer so I will have to get hold of it and the apply your design.

    Best

    Krister
  • ebsebs Posts: 111 ✭✭
    Here is the XML* for the example rule if you don't have Rules Designer installed.

    *Generated from OC3.4.1 but should be compatible with other versions

    Cheers
    Eric
  • kristiakkristiak Posts: 1,249 ✭✭✭
    Thanks Eric,
    Does this mean that I have to have a rule for each of the combinations that would not be allowed, e.g. one rule that checks field B vs D and one checking field B versus E and one that checks filed C versus D and one that checks field C versus E
    Sorry about all these questions :)

    Best

    Krister
  • ebsebs Posts: 111 ✭✭
    I would have one rule per field you are checking to ensure is blank. The target of each rule being the field you want to check is blank and for the message to be displayed for (the ! in my above screenshot).

    Therefore something like:

    1. Target FIELDD, checks that FIELDB, FIELDC and FIELDD are all populated (i.e. FIELDD shouldn't)
    2. Target FIELDE, checks that FIELDB, FIELDC and FIELDE are all populated (i.e. FIELDE shouldn't)
    3. Target FIELDB, checks that FIELDD, FIELDE and FIELDB are all populated (i.e. FIELDB shouldn't)
    4. Target FIELDC, checks that FIELDD, FIELDE and FIELDC are all populated (i.e. FIELDC shouldn't)

    I think that covers all your scenarios.

    You could probably have less rules by checking all four fields however you can't then point the user to the incorrect value very easily.

    Cheers
    Eric
Sign In or Register to comment.