4 Replies Latest reply on Sep 4, 2015 12:05 AM by LuukvanSummeren

    Field Validation using conditional value list




      Im trying to validate a field using a calculation but im getting stuck somehow.


      In my database I have a table with students, every student has a username to login to an NMR system

      A user can either be active or inactive

      I made a conditional valuelist with the usernames of all active users using

      Now when i enter a username for a new user I want to check that it is not allready in assigned to an active user.


      my calculation looks like:

      IsEmpty( FilterValues ( ValueListItems (Get ( BestandsNaam);"Unames"); student::Uname))


      when i run this calculation in a script it seems to be working fine. An occupied username returns 0, a free username returns 1

      but when i use this calculation to validate the Uname field i get an error message saying that the entry is not valid even when i enter a unique username


      I cant use the unique option to validate because i have students in the database that are inactive and their usernames have allready been deleted form the NMR system so they are reusable.


      What is going wrong, and how can i fix this?


      Thanks in advance

        • 1. Re: Field Validation using conditional value list

          Hi there,


          In the script, you can control at what point you want your process to be triggered, such as onModify or onValidate.


          In the Field Definition in Manage Database, you do not get that ability. So, when you put that calculation into the field definition and change your Uname value, you run through every script trigger until you hit onValidate. onValidate follows onModify. onModify is a post-script trigger and will run after the value has been modified. This will update your value list. your onValidate will see that the value is in the value list and run the error.


          I would suggest going the script route or if you want the field definition approach, you will need another field to act as your validation, so the value list does not get updated.


          I hope this helps.

          • 2. Re: Field Validation using conditional value list

            So if I understand you correctly you are saying that the value is being added to the value list before the validation takes place.


            The script route would be okay, however normally we manipulate data in table mode and i dont think there is a possiblity there to active a script when data is entered. But this problem should be solvend by using list mode i guess.


            Thanx for the answer

            • 3. Re: Field Validation using conditional value list

              If you add the field in layout mode and set up triggers they will fire in table mode as well.

              This way you can define drop-downs, calendar drop-down etc for any field.

              • 4. Re: Field Validation using conditional value list

                So i managed to get it working, it turns out that the value is being added to the list as soon as it is entered in the field.


                My solution:

                So when i enter the field a script is triggerd and the list with occupied usernames is stored in a global variabel

                this list is used in the validation process