How to record/store values from a User Specific Column?

Hello Glide Community,

I’m currently developing a fantasy league game in Glide focused on crypto.

In the “token” sheet, where each row corresponds to an asset that a user can hold in their portfolio, I have a user-specific column containing the quantity of tokens each user owns.

Users can make strategic moves (e.g., market manipulation) to benefit or harm a token, affecting all players who own that token.

When a user uses a strategic move for token A, for example, a new row is created in the “moves” sheet where the multiplier resulting from the move is calculated. With a relation between the “tokens” and “moves” sheets and a lookup, a multiplier is assigned to token A.
A math column multiplies Token Value (a math column using a user-specific column) by the multiplier, determining the effect the booster had on each user.

My issue is: how do I record/store the value for each user of the “Move $ result” column?

Currently, this value is overwritten as soon as a new move involving token A is made.
Additionally, if a user sells their holdings of token A, it will modify their Token Value and consequently the value of “math_Move $ result.”

I need the value resulting from the strategic move to be saved at the moment the move is made, so it can be applied to the cash balance of each user involved.

I tried with an increment number action that sum in a User Specific Column the value of “Move $ result” but it works only for the User that makes the move, not for all the users who own that token…

Any assistance or guidance on how to achieve this would be greatly appreciated.
Ty!

I might want to know this first. Why do you store the amount each user holds in a user-specific column?

Hi @ThinhDinh

Recording token holdings in a user-specific column was an old implementation I had made before your suggestion a few days ago.

I haven’t completely removed this implementation because I have two screens that source from the “tokens” sheet where I need to display user holdings in a collection, and here I haven’t been able to make your solution work, so for now, the user-specific column with token holdings is convenient for me to bypass this issue.

That said, we can also ignore the user-specific column and consider alternative methods.
The goal is to ensure that whenever a strategic move is used on a token, all users who own that token are credited with a value corresponding to the effect of that strategic move, which depends on the amount of that token each specific user holds.

All token trades that users do are stored in rows inside the “orders” table.
In each row, we also have the holdings balance, for the user who made the trade, of the traded token (column: rollup_this row token balance)

All moves that users do are stored in “moves” table.
In each row, the effect of the move is calculated by rolling a die and using an if-then-else column that generates the multiplier resulting from the move, based on the die’s outcome.
The multiplier should then be multiplied by the value of the holdings of each user who owns the specific token.

I am also willing to pay for consulting if the help I’m asking for is too burdensome. I really appreciate your availability but I don’t want to ask too much :slightly_smiling_face:.

So what you’re trying to do here is if a user makes a move, then you want to change the amount of tokens other users hold?

Not exactly.

If a user makes a move with token A, then:

  • Calculate the multiplier for that move (currently done using dice + if then else).

  • Apply the multiplier to the $ value of that token held by each user.
    For example, if a user holds 100 tokens A and the price of token A is $1, the $ value held by the user is $100. If the multiplier is, for instance, 0.8, then the effect of the move would be -$20 for that user.

  • Then, I want all these effects for each user to be stored and accumulated in a column in the user table. This way, I can sum this value to the “Cash Available” column to finally obtain the desired result (total $ effect of moves for each user in the entire League).

So when user A makes a move for token A, you need to calculate the “effect” for user B, user C, etc - all users who own token A?

Each “effect” would result in a row in a new table as well?

So when user A makes a move for token A, you need to calculate the “effect” for user B, user C, etc - all users who own token A?

Correct, I need to calculate the effect for all users who own token A (user A included if he owns token A).

Each “effect” would result in a row in a new table as well?

Each move made will result in a row in the “Move History” table, where I can obtain the resulting multiplier for that specific move.
To get the “effect” I would have to multiply the multiplier by the $ value held by each user (so there will be as many “effects” as there are users who own that token), but I’m not sure about where and how I should do this.

Now that you mention it, creating a new table where each row represents the effect for each individual user maybe could be a solution… But this means that for every strategic move used, several new rows must be automatically added to this new sheet, one for each user who owns the token. Is this possible?

Yes, isn’t that what you want?

If there’s a way for you to cast that “multiplier” to all the rows in the Order History table, you can:

  • Calculate the effect the move has for each relevant row.
  • Construct a JSON containing the “effect”, and the tokens before and after the move for each relevant row.
  • Then, you can construct an API call body template for each row in a JSON column.
  • Query to take only relevant rows to the move, and join the API call templates together. At this point, you can use the Call API action (if you have access to it) to add multiple rows, or send the info through a webhook payload to Make.com.

It’s pretty complex since you must only act on unique rows for each combination of user and token, but that’s the best way I can think of for now.

Hey @ThinhDinh,

thanks for your help.

I’m trying to follow your instructions, but I would need some clarification.

To cast the multiplier to all the rows in the Order history table I created

  • a relation with the Moves table
  • a lookup to get the multipliers resulting from all the moves that involve token of that row
  • a single value column to get only the last multiplier (so the multiplier of the last move).

Then a math column to calculate the $effect of the last move. Would that work for your solution?

Does the JSON content serve to fill the multiple rows that will be created in the new sheet, right?
If so, I believe that User ID and $effect might be enough. I didn’t understand what you mean by “the tokens before and after the move”.
Am I missing something?

Is it necessary to have a Glide Business plan to do this?

Thanks a lot for your patience :pray:

That looks like exactly what you need. However I don’t want you to log multiple rows for a combination of user - token, so make sure there’s a part where you:

  • Query the same table to target same user ID and token ID.
  • Get the first rowID from that query.
  • Add an if-then-else column. If rowID is “first rowID” then return the JSON, else do nothing.

Yeah that should be it. I was just asking to see what kind info you want in the log.

Call API is only on Business/Enterprise, so if you don’t have that, you can use the Glide API with Make, perhaps.

What if I just set column values as in the screenshot for the webhook? Would it work? I’m not really getting what I have to do with the JSON object and the JSON template.

Also I have to study better how to set Make Scenario properly.
I feel quite stuck :sweat:

Please check this out.

What I’m thinking is batching the calls using the mutations array here.

I’m not sure I fully understand here, but if you say you want to do a set column, you can’t do it multiple times, dynamically, using that action.

I think we’re close… can you tell me where the mistake is?

So I’ve got a JSON template column for each row.

Then I made a if-then-else column that shows JSON mutations only when needed.
image

Then I made a Join list column to batch all the mutations, comma separated.
In this case only 2 users are hit by the move effect, so we have 2 mutations and we want to add 2 rows in the “Move Effects” table.
image

I also made a JSON Body template column where MUTATIONS is replaced by the list of mutations
image

Here the action:

When I run the action it’s succesful, but nothing happens in the “Move effects” table.

In Make there is a webhook and HTTP Module


You’re my last hope! :pray:

Several issues.

Firstly, when using a JSON Template column to create a collection (of mutations), you need to feed it an array. A Joined List column is not an array. So you should instead use a Lookup column to get an array of mutations.

Secondly, you are including your (broken) mutations in your request body, and then also sending them as a separate value:

CleanShot 2024-05-13 at 01.22.43@2x

You don’t need to send the mutations separately, so get rid of that.

Thirdly, you can see from the Action log that your body contains an empty object for the mutations, as opposed to a collection:

I’m not exactly sure why mutations are being sent as an empty object, but I suspect it’s related to the first issue (joined list vs lookup).

Anyway, all of this results in an invalid payload that is sent to the Glide API, which rejects it with a 401 Status code:

So, the first thing you need to do is get a valid JSON payload being sent. Once you fix the mutations, click into your JSON Body column, copy the contents and paste it into https://jsonlint.com/ to validate it.

Even then, you might find that you can’t pass that straight through to Glide without first parsing the JSON with a JSON Parse module.

1 Like

Hey @Darren_Murphy Thank You!

I made the fixes you suggested and then found an error in the JSON template body:

{
“appID”: “XDClBguiExzBhtaRObar”,
“mutations”: [MUTATIONS]
}

I added a $ in front of MUTATIONS and then worked.

However, there are still issues with the HTTP module giving a status code: 401.
Do you have any suggestions for this?

Are you sure you’re referencing the right value in your HTTP call? The mutations value there is still an empty array.

image

Can you give a screenshot on how you’re setting up that HTTP module? I’m not sure if using “API Key Auth request” has much difference compared to a basic HTTP module.

Hi @ThinhDinh,

here the current configuration of http module. I also changed the module to basic HTTP.

Here the result of the call. Nothing happens in “Move effects” table.

Your request content should be the entire body.

But even with that, I still think you will have problems. In my experience, when you create a JSON payload using the Glide JSON columns you cannot simply pass them straight through to the HTTP module. You need to pass them through a JSON module first.

Have a watch of the below tutorial. It walks you through how to set that up:

2 Likes

I’m trying to follow the tutorial but when it comes to fill the columnValues, as in the screenshot, I just have these options to insert and it doesn’t seems to be right.

Any suggestions?

Click the Map option for mutations.