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.
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
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.
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.
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