Update users points from outcome of a form

This is so simple, and I don’t know why I can’t figure it out :frowning:

I have one Data Type called Bet Info and in there it has a list of “winners” and “winners points” as well as “losers” and “losers points” my other Data Type is Users and in there I have “points” (screen shots below). Very simply I want to:

  1. For users who are “winners” add “winners points” to users existing “points”
  2. For users who are “losers” subtract “losers points” from users existing “points”


Please help! I’m not sure where to do this calculation. I have tried adding it to the workflow when we close the bet and update who the “winners” and “losers” are but I can’t seem to get the formula right (see below).

And I have tried adding it to the profile page, but it doesn’t sum the “winners points” it just lists them (screen shots below).

Thanks!

I don’t think your data structure will support what are trying to achieve. You can’t have a list of users for your winners, because there is additional data you are looking to store that is specific to the combination of bets and winners (and losers).

Think of your betinfo data type as master or header data, where you will keep track of the overall bet. And then you need to create a new data type for your transaction data.

Try this:

  1. Create a new data type called something like “BetDetails”.
  2. Your BetDetails will include fields for user (link), betinfo (link), points and something like winorlose.
  3. Then in your workflow, when you close the bet, you will create new records in this data type for all your winners and losers for this specific bet.

Thanks for your help!

I have a few questions. What do you mean by “link” for the fields? I created the data set as you can see below. Is that what you had in mind?

I’m still a bit confused as to how I do the calculation when I close out the bet. I’ve added a step in the workflow to add the winners points and the losers points to my new Data Type “Bet user details” but still not sure how to tie that to a calculation to update the winners and losers points.

Firstly, your losers points should be of type number, not text.
You’ve set up the data type correctly to achieve what I mean by link. Now you can create many bet details records and “link” them to their appropriate master records “bet” and “user”.

I believe your next step will be to set up a backend workflow to create a list of bet details. You will need a new record for each user and whether they are a winner or loser, and the associated points. Again, I don’t think you can achieve what you are trying with a list of users.

I suggest reading this manual, and especially the part where they address “data types and data fields” and “linking objects together”.
https://docs.airdev.co/canvas/using-bubble/bubble-best-practices/database

That was helpful, and very informative - thank you!

However now my challenge has just changed. Since I now have 3 different Data Types - Users, Bet info, Bet user details - I am having trouble pulling all the data together on a single page to summarize the bets and the details.

For example you have to set a page to a specific Type of Content and now I can’t pull in Bet info and Bet user details.

Or if I try to create a repeating table to pull in all bets so that users can see a log of all bets, a repeating table can’t take 2 Data Types (I would want Bet info and Bet user details).

Surely this is a simple problem to solve, but I’m having trouble wrapping my head around how to work with multiple data types and the resources I found are mostly about setting up the data and “linking” them but not how to work with multiple data types.

I think the problem may be when I am “Creating” the data in the first place. How do I tie the data types together so that when I “Create a new Bet info” that Bet info is linked to the “Bet user details” when I “Create a new Bet user details”?

You’re well on track and about to hit a key learning pivot point (or at least what you’re about to learn was a big milestone for me). Can you please share a screenshot of an update of your various data types as it will help the conversation.

Yeah, feels like I am on the edge of a breakthrough for sure. Please see the data types below:

Your data structure should now be fine. You have successfully:
Linked user to bet user details using the Bet Owner field as a user data type, and
Linked Bet info into bet user details using the Bet Details as a Bet Info data type.

Now…
when you create a new bet user details, you will need to tell it which bet info you want to link in. So Set Another Field and select bet info, and you should see “Result of Step 1”…

Hey @mike.sorgenfrei !

I thought I’d film a quick video to show you how I would set something like this up. Not entirely sure about the specifics of your app, but here is how I would set up my db for a very simple “betting” app. Let me know if you have any questions.

@SerPounce this is so helpful, thank you. This really made me understand how to get the links to work together better.

@jacobgershkovich love the video! Super helpful and you were exactly right on how to think about the data. My challenge, which is a bit different, is that rather than just winning or losing against a “game”, in my app users are “challenging” each other so I have to have more data around who is challenging who, who is accepting / denying the challenge, etc. etc.

Thanks to these posts I can now get the data to show correctly in repeating tables, and across bet details / summary pages. However what I am struggling with is still updating a users “points”.

Here is a link to a spreadsheet that I created to try and organize the data. I copied the template from the article @SerPounce shared earlier (thanks again). It feels like I have two challenges, but haven’t been able to crack them myself:

  1. Am I missing one or two more critical links between data types?
  2. Where should I be calculating the user “total points” formula? Is that done in a Workflow, or directly in an Input field with dynamic text?

In general, I know what I want to do, screen shot (it’s in the spreadsheet too) below, but I can’t seem to bring it all together - again I think it’s because of the two challenges above.

Thank you SO much for all your help! This has been incredibly helpful, and have already learned a ton.

I’ve tried to simplify my data structure even more, but I still can’t get this to work. I feel like I am very close, but don’t know what I am doing wrong or what I am missing.

What is working:

  1. User can create a bet with a wager and challenge other users
  2. Users can either accept or deny the challenge creating a list of “confirmed players” for each bet
  3. User can settle up / close the bet and assign who won and lost

What I am not able to figure out is how do I update the “winners” and “losers” “total points”

Here is a link to the updated spread sheet that outlines by data, and below are screen shots of my data type. I’ve also included screen shots of the workflow I am trying to build when someone settles / closes the bet. I assume that’s where this calculation / update to “total points” will be, but I can’t get the changes to work.

My goal here is to update all “winners” (Data type = bet players) and “losers” (Data type = bet players) “total points” (Data type = User) by the amount (number) of the “wager” (Data type = bet info) thank you in advance for any / all help!