set a lookup field as unique
Posted: 2020-11-17 15:42
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
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