create a custom error message if a field's data already exists and prevent the record from being saved

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
fgazza
Veteran Member
Posts: 128
Joined: 2019-04-30 17:37

create a custom error message if a field's data already exists and prevent the record from being saved

Post by fgazza » 2019-08-16 13:44

Hello.
I have a table with the fields "name" and "surname"
I created a "name_surname" field in which the fields "name" and "surname" are automatically concatenated.
The "name_surname" field is set as unique.
I would like if an "name_surname" field already present in the table appears as an error message such as "this name is already present in the database - it is not possible to re-register an already present name. Cancel the creation of this record and modify the record related to the name already registered "
How can I do?
Thank you!!!
Fabiano

onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 482
Joined: 2019-05-21 22:42
Contact:

Re: create a custom error message if a field's data already exists and prevent the record from being saved

Post by onoehring » 2019-08-17 06:32

Hi Fabiano,

I suggest you use a hook (before_insert). Just test if name_surename already exists, if not, show some JS error and cancel the insert.
BTW: Are you sure, that name_surename is unique?

Olaf
Some postings I was involved, you might find useful:
Backup your database (viewtopic.php?f=4&t=3341); Improve security (viewtopic.php?f=4&t=3168); Field Permissions (viewtopic.php?f=4&t=3308); Custom (error) message (viewtopic.php?f=7&t=1740&p=10871#p10906); Audit Log (viewtopic.php?f=4&t=1369&p=10407); Two Factor Authentication (viewtopic.php?f=7&t=3306&p=11478); Add 2nd SAVE CHANGES button (viewtopic.php?f=2&t=3242&p=11104); Place a search on details view (viewtopic.php?f=2&t=3479&p=12484#p12484); Column-Value-Based-Permissions (viewtopic.php?f=4&t=3498)

onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 482
Joined: 2019-05-21 22:42
Contact:

Re: create a custom error message if a field's data already exists and prevent the record from being saved

Post by onoehring » 2019-08-30 08:13

Hi fgazza,

please see my solution here: viewtopic.php?f=7&t=1740&p=10906#p10906
Does this fir your needs?

Olaf
Some postings I was involved, you might find useful:
Backup your database (viewtopic.php?f=4&t=3341); Improve security (viewtopic.php?f=4&t=3168); Field Permissions (viewtopic.php?f=4&t=3308); Custom (error) message (viewtopic.php?f=7&t=1740&p=10871#p10906); Audit Log (viewtopic.php?f=4&t=1369&p=10407); Two Factor Authentication (viewtopic.php?f=7&t=3306&p=11478); Add 2nd SAVE CHANGES button (viewtopic.php?f=2&t=3242&p=11104); Place a search on details view (viewtopic.php?f=2&t=3479&p=12484#p12484); Column-Value-Based-Permissions (viewtopic.php?f=4&t=3498)

Post Reply