Probably Easy ... check if record exists based on multiple values

This is probably another really easy thing that I am over thinking. I know how to validate and prevent a database insert if a record value exists. Works wonderfully.

Now, I need to check two fields in the same record.

Field One: Program Name
Field Two: Client ID

Client can be in the table many time, and program name can be in the table many times. What I need to prevent is Program name and Client ID from being entered again in the same record. So no two records can have the same Program Name and Client ID combination.

Hope that makes sense. I am sure it is easily done and I am just over thinking it and it’s too early for a beer.

I don’t think you can do this with the Validate action…you’ll have to do a query to see if it exists with conditions on both fields, and then a condition that only passes when the count of that result is zero. You could also add an index to the db to ensure it never happens and just catch the error on insert.

3 Likes

I am sure there must be a way to make sure duplicate records are not entered into a table?

Yes Brad,
This should be done exactly as Ken explained.

Use a query, filter it by the values entered in BOTH fields and then add a condition.
The condition should check if the query returns a result. If the query returns a result this means a record containing these two values exists.
If it does not return a result you can run the insert step.

Thanks Teodor, I will see if I can wrap my little old brain around that. You guys make it ‘sound’ easy.

If you have filtered a query in Wappl already, it’s not harder than that.

Maybe this helps…

3 Likes

Hmmm, interesting. Thanks to both of you. I will work away at this. You have provided good hints.

1 Like

Wow Ken, your wizardry is astounding! That is a great idea!

1 Like

Ha! Well I don’t know about that J.R. but nice of you to say.

1 Like