Hi to all,
i need to set a lookup field as unique to prevent the creation of two records with the same value in a lookup field by also showing a custom error if the field contains a value already present in another record.
Unfortunately appgini don't allow to check the option "unique" directly in appgini tool and if I attempt to do it appgini give an error when I go to generate the app (erros is "a field cannot be a foreign key and a unique field at the same time").
So I'm asking if you can help me with the code to put in hooks file or -dv.js file to prevent the creation of two records with the same value in a lookup field by also showing a custom error if the field contains a value already present in another record of that tabel.
Thank you so much!
Fabiano
set a lookup field as unique
Re: set a lookup field as unique
Hi,
do you need the lookup table to contain every possible option, or woud it not be better to only show the available options?
If the later makes sens for you, you could adjust the lookup sql to exclude the already existing entries.
do you need the lookup table to contain every possible option, or woud it not be better to only show the available options?
If the later makes sens for you, you could adjust the lookup sql to exclude the already existing entries.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: set a lookup field as unique
Hi and thanks! The idea to only show the available options sounds great.
Would you be kind enough to offer me a code simulation?
Thank you so much!
Would you be kind enough to offer me a code simulation?
Thank you so much!