Search for combo of records before submitting to database

Hi Everyone,

I have a simple form which contains 2 items, a City name and a colour.

I have a table with the same 2 items. I want to check if the combination of items exists before submitting, so if London/Red exists together in the database then it will show the error message if you select London from the Dropdown box and enter Red in the input, if not then it will submit to the database. I’m searching for the City name & colour in the ‘Only When’ workflow and using the inputs for the source then if either are empty or not empty, running the relevant workflow but it’s not working and I’m not sure where it’s going wrong. I’ve tried different things in the
‘Only When’ box but I can’t seem to find the solution. Maybe I’m making it harder than it actually is?

So my goal is the City can appear in the database many times but only with a colour once

Please can anyone help?

I’ve put a screenshot and link below if this helps?

Many Thanks

Instead of “is not empty” after the search for tables:count try Search for Tables:count is not 0. Because the way I see it the count will never be “empty” because 0 is technically a value.

@foraanyas provided the slight change you need to make. I want to point out that you should consider front-end validation to provide a better and quicker user experience…

Thanks both for your suggestions, the small change @foraanyas suggested appears to work as expected but since you suggested front end validation this could be a better solution.

I’ve attempted a go at this but I’m not sure if I’m achieving it in the best way - I’ve added an input box to the page (I guess I’d use an invisible element ultimately but this way I can visually see it working while building) and this input box has an initial contend of the same solution as suggested by foraanyas. So this shows either yes or no.

I have a couple of conditions on the button and ‘Already exists’ text to either be hidden or visible depending on the value of the new input to stop the user being able to actually click the button if it already exists.

The only issues I have now is the show/hide conditions aren’t always ‘snappy’ if you get what I mean, so they can take a second to update based on the input changing but despite this you can’t seem to trick it by quickly clicking the button on an invalid input, it seems to always catch up so I’m not sure if this is a potential problem or just something I can live with as long as it doesn’t allow the user to submit a duplicate entry.

I think the only 2 actual issues which was also an issue with the original backend solution is that it ignores the case of the letters, so Red, red, ReD & "Red " (trailing space) are all unique values and allows submission. I’m not really sure how to overcome this, could I add some kind of formatting somewhere to only allow Capitals, numbers and -'s etc or is there some other better way?

Cheers for your help

The front end validation can work in various ways. For example, you can have a spinner show while determining if a duplicate. But here since there are two fields that are combining to determine if they are a duplicate, I’d consider (based on how many possible matches there are) creating a hidden RG of matches to the first input. That would allow for easier validation to check if the second input exists in the hidden RG.

In terms of the mismatched case, you can either do a search by keyword (which is not case sensitive) OR assuming that the back-end data format is consistent, format input to match - meaning a) all capitals, b) find and replace other characters that shouldn’t be there and c) trim.
image

Side point: Are you sure you want a input and not a dropdown?