Determine if row exists in a table

Hi, I have a column that I use as a relational “multiple select” and it works fine. Why can’t I interrogate that field in the current row to see if a value already exists? I am trying to avoid writing duplicate records. I have it populated with the Row ID of another table (by using relations). Is there another way to avoid writing duplicates to this secondary table?

We would need more screenshots from you to know how you are setting it up.

Normally, if I want to check if a value is duplicated or not, I use a custom form, then create a relation from the input field to the list of existing values. If the relation is not empty, that means there’s a duplicate and we should not allow a form submission.

Hi, well, I did that, but it only allows me to check for IS EMPTY or IS NOT EMPTY. I really need to check IF CONTAINS to the relation field. Here is the check…
image

And here is the relation field. This seems to work OK. I don’t want the same people to click the ADD ROW button twice.

Which value are you using to build the relation?

If your target table contains the email address - which seems to be the case - and you’re trying to prevent duplicate entries from the same user, then your relation should be formed by joining the email address of the signed in user with the email address column in the target table.

Actually, if I’m understanding your use case correctly, you don’t even need a custom form. Just add this relation column to your User Profiles table, and if it’s not empty then don’t even show the Add Entry button in the first place.

Well, here is the Row ID from the “Intentions” table:
image
And here is the “Intentions Row ID” from the “Prayed For” table:
image
So, to your point, I am not sure why it is showing the email address in the relation column. You can see I am using the two Row ID columns as the relation. At any rate, the User table really has nothing to do with it. The same user can click the “Pray for” button on each intention, but I don’t want them to be able to click it twice on the SAME intention. Right now they can.

That doesn’t really mean anything other than telling you that the relation is not empty.

Okay, what you need to do is create a template column in your Intentions table that joins the intention ID and user email address columns. Then build a similar template column using the selected intention ID and signed in users email address. Then use those two columns to build your relation. If it’s not empty, then you have a potential duplicate.

1 Like

Well, and for reasons I cannot understand, because I made no changes at all, now the relation is showing the Row ID. So, in essence, the relation really needs to be (Row ID + Email) in order to prevent duplicates. But I don’t see that it’s possible to make that relation, and if I could, it does not seem possible to interrogate the contents of the relation – only “is empty” and “is not empty”. So hopefully someone has another way to do this…

Exactly. See my previous reply.

The relation just establishes a link between two datasets. To access data via the relation, there are other column types available - Lookup, Joined List, etc.

So for example, you could create a Joined List column through that relation to get a list of all email addresses. Then you could use that with “is included in”. But that would be quite convoluted and completely un-necessary in this case, because…

Thank you. This solution worked perfectly (create template column in main and sub table and a relation column in the main table). I used the is empty to display the add row button or not. I now have several columns I didn’t think I’d need. And I’ll probably go back one day and wonder what they’re for. But hopefully, I won’t delete them.

Glide Best Practice #42: Never delete a column before first doing a Find All Uses :wink:

3 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.