This topic is locked

Prevent Duplicate Values Issue

3/5/2016 9:46:15 AM
PHPRunner General questions
M
mhollibush author

I have a form that checks for duplicate values,
the issue is when there is no data in the field I get a error stating that the value already exist.
This is not a required field, but when used it needs to check for duplicate entries.
how do I get around a empty field with Prevent Duplicate Values?
Thanks

Sergey Kornilov admin 3/5/2016

This is the way how this feature works.
If you need to prevent duplicate values and also allow empty values you need to use BeforeAdd event and check for these conditions manually.

M
mhollibush author 3/5/2016



This is the way how this feature works.
If you need to prevent duplicate values and also allow empty values you need to use BeforeAdd event and check for these conditions manually.


Can you please give me an example of how the code should be written... a little confused on this

Sergey Kornilov admin 3/6/2016

I do not have an exact code example but here is the pseudo code for BeforeAdd event

if (field value is empty) {

return true;

}

execute sql query checking if such value already exists in the database

if (found) {

return true;

} else {

$message="Duplicate value found in field ...";

return false;

}


More info on BeforeAdd event:

https://xlinesoft.com/phprunner/docs/before_record_added.htm