Referral system with unique codes, verification problem

I made a referral system. The user registers, then a window appears where he can enter the code of another user. After entering, the code is saved, and the new user goes to the products where he can view them, and the user whose unique code he entered will receive a discount depending on the number of people that he brought.

The problem is that when a new user enters a referral code and then clicks on a button, which causes a small “Action”. And there in this “Action” I have a check that the entered code must belong to someone.

I have in the table a column with all users taken using “Query” and a column with “Joined List”, where all the keys taken from the column with “Query” are located, and in “Action” I set the condition that the code entered by a new user must “is included in” to the column with “Joined List”, and so, the user enters the code and it works, saves the code of the new user and gives another a discount.

But the problem is that even if the user enters half of the full referral code, the Glide check will count that it is correct, which means it can also be written down, but the discount will not be given to the person who gave this referral code, but as luck would have it, whose unique number was closer to this code. In general, the problem is with “Joined List” and “is included in” and what could be done here? :sweat_smile:

I think on the screen where you have users enter their buddy’s referral code:

  • Add a user-specific column to store the temporary input on the screen.
  • Add a relation from that input field to the list of referral codes assigned to each user.
  • If there’s a match, then you allow the user to proceed, setting the value of that input to a basic “referral code entered” column. You will be using this column going forward for discounting purposes.
  • Else you show an error that the code has already been taken.