Assign referral code for each user

Dear Team,

I am creating an app where I want to assign a unique (XXXX1111) referral code to each registering user in the letter and number format by using firebase. Can some help in personalising the first 4 letters to be specific so that XXXX never changes but the numbers 1111 changes. Request for assistance.


then it can be anything as of your choice

you can keep a count of registered users in a tag starting from like 1111,
when user successfuly signup call that tag and join it’s value with xxxx
and then in firebase store the new value = got value + 1


Welcome !

The 4 letters Don’t change? But are they useless? 4 letters, should mean some identification. And the 4 digits 9999, should they have 0 on the left? 0001,0002,0099,0199 …

You should use join element to join XXXX & "a random number between (yournumber , yournumber)
and later whenever someone join’s make the value +1…It’s A Bit Confusing… :sweat_smile:.Hope it works… :grin:



Download links
Refer.apk (5.2 MB)
Refer.aia (3.6 KB)

i think it carries chances of being repeated at some time.

(i can be wrong)


Yes. For this reason your need to check in your database

1 Like

But in that case,
if the user base is large it will take time to verify the unique code.

But dont know how much time.
Might take very little.
Then it will be :+1:t2: :heart:


Depend on your database. :shushing_face:

Hi Rodgerio,

Thanks for the reply.

Yes, the 4 letters has a meaning and should remain as is, only the number should be changed.

I don’t understand non-relational databases. Maybe this:
Create 1 elements to have the sequential number, which will be increased by +1. This sequential number, if 0 is needed on the left, create a procedure that does this.
1-Code field = 1 Take it from the non-Relational database, put it in a variable, add + 1 to this code field in the database.
2-Place the left 0 in the variable.(your procedure)
3- Join the XXXXX-
4- Returns and writes to the database.

Are you using Firebase? If yes,
Store all referral codes in a JSON object, let’s assume it as ReferralCodes
Use getValue block,

Tag should be:


If it returns NotFound, then the code doesn’t exist.
You can assign the code to the user.

1 Like