Such as not being able to add a contact into the โContactsโ table if they already exists; same with Products, Clients, Users, VehicleIDs, What-Have-Yous.
Preventing duplicates in this way is very straight-forward in AppSheet; all you need is a validation formula in the Valid If space for the column you want to prevent duplicates on.
Not(In([_THIS], SELECT(Table[Column_Name_for_THIS_Column], [TableID] <> [_ThisRow].[TableID])))
What youโre really accomplishing with this formula is youโre pulling a list of all the values from [Column_Name_for_THIS_Column], then youโre seeing if the value entered by the user (thatโs the [_THIS] part of the formula) is inside that list; but youโre also removing from that list the very record youโre working on.
Letโs say I have a Users table with the following properties:
If I wanted to prevent duplicate user names, I would put the following formula inside the Valid If formula space for the User_Name column.
NOT(IN([_THIS], SELECT(Users[User_Name], [UserID] <> [_ThisRow].[UserID])))
This would prevent users from being able to enter the same name twice, but still allow them to enter it once.
When this formula processes, what it does is:
If I were to give you an example of this (continuing from the GIF above), the list looks like this:
Matt V, MultiTech Visions
If I came into the form and tried to enter โMatt Vโ again:
Oh I see. Thank you very much!
This is a better solution designing -
NOT(IN([_THISROW].[Date],SELECT(Doc[Date],
AND([Date]=[_THISROW].[Date],[ID]<>[_THISROW].[ID]))))