How can I update a field of another user? Need help


I have a bit of a sticky problem I could really do with some help with.

I’m building a charity app which has a refer-a-friend invite option (this uses a unique referral code attributed to each user at sign-up who sends the referral code to someone they want to invite to the app).

The reason I use a unique referral code is I want the actions (money donated etc) of the referred (the child) to be attributed to the inviter (the parent).

However, I just can’t figure out a way to attribute the actions of one user to another user.

I have a user collection (obviously) with a ‘ReferralCode’ field and a ‘ParentReferralCode’ (the parent referral code, if there is one, is filled in as part of the sign-up process).

I also have a ‘MyGivingActions’ field which records money the user donates.

The key issue I need help to figure out is how to update a ‘ChildGivingTotal’ field which will record the giving of my ‘children’ (and their children).

The child is linked to the parent by the referral code, but how can I update the ‘ChildGivingTotal’ of another user (my parent)??

I’ve been trying to figure this out for a couple of days…I’m stuck, like properly stuck!

You would have to get creative on this one. I don’t have much time to post a full tutorial but the way i would address this is…

Create a referral code collection with a few fields such as created by (referrer), referral code (you can use the RAND function to generate) and ‘friend’. To create a code, make sure there is a ‘refer a friend’ button and an email input field. When pressed, set an action to create new referral code and populate the field as follows:

created by = current user
referral code = custom formula (function rand)

You can then have a text field that shows the outcome of the custom formula (current user > referral code > referral code). They can then copy and send to other people or you can set it up to add an email input field that you then link to an email API and it send the code via email.

For the friend signing up, on the signup page, do a custom list of all referral codes and add a + icon in the list (no text or anything else, just the icon). Put this list next to an input field which is where the user will put the referral code. Set the list custom filter as follows:

referral code = referral input box.

So if the referral code is in the referral code collection then the + plus button will appear.

Set an action to the referral code + button that says:

update current referral code > friend > current user. Then another action to go to another screen.

For the rest of what you mention, this is all down to the relationship between your collections. If you have a join collection like the referral code collection that I mentioned above, two users will always be connected through that connection so then you can update each users fields every step of the way. Does that make sense?


Thanks for this, it’s the end of the working day here (UK), but I’ll take a look tomorrow and have a proper read through.
Appreciate your help though :slight_smile:

1 Like

Hello crmorris2, do you think it’s possible to make a tutorial? I’ve been trying to do this but apparently I am not succeding… let me know! :sweat_smile: