Skip to content

Check if record exists in the database on insert

teodorpk edited this page Aug 1, 2018 · 2 revisions

Using the server-side data validation you can check if a record already exists in the database. This is useful when creating users so you can check if the email is already registered and if yes, you can show an error message and don't allow insert.

Select your Insert Record action(1) and right click the step before the insert record step(2):

Select Validator:

And then Add Validate Data:

Select validate data step and click validate options:

Click the add new button:

Double click the expression field so that the dynamic data picker appears. Click the dynamic data picker:

And select the POST variable (form input) which value you want to validate. In our case this is the email input:

Then add new validation rule for the selected expression:

Open the Database category:

And select Does not exist in database:

Select your database connection:

Select the database table you insert your data into:

And select the database table column to check for existing record:

Customize the error message that will appear if a record exists:

In the linked field enter the name of the form field, which is on your page. If you don't do this the error message won't appear on the page:

Click Save:

Then save your server action and you are done. The insert won't run if the record already exists in the database.

Clone this wiki locally