How do I Deduct a Value Stored in State from a Value Stored in Data?

I need to deduct value A (which is a numerical value stored in state on-click), from value B, which is stored in a database and relates to the number of paid credits the current user has remaining.

Can anyone help me out with regards to how I would go about this? Could it be done in the workflow right after I obtain value A?

Hi there, @blogshackltd… if I understand your post correctly, yes, you should be able to deduct the value stored in a custom state from a value stored in the database after the custom state has been set in a workflow. Have you already tried doing that and it’s not working for you? If so, can you share some screenshots that show what you tried?


Hi again @mikeloc

I don’t really know where to start, because I don’t know what the mathematical operators are. I assumed it would something like: database-credits-field - state-tokens-field but when I try that I get a message telling me I am trying to change a field and not a thing:


I think the - operator relates to list manipulation and not mathematical operations as per the help docs. I can’t find any info regarding how to actually perform the deduction, I know how to select the variables I need to perform the deduction on.

If the field and the custom state are both numbers, you can perform mathematical operations on them. The message you are getting is something else, though. You aren’t setting the workflow up correctly, and without knowing a lot more about what you are trying to do, it’s pretty hard to help. In general, though, if you are trying to make changes to a thing, set the thing to change to the actual thing, and then change one or more of the thing’s fields.

That’s exactly what I am trying to do, both the data and state variables are numbers, but I get this popup when I try to add the deduction to my workflow:

I am trying to deduct the value contained in the variable set in step 4 from a numerical value stored in a custom field added to user database.

The thing you are trying to change should just be Current User. Then, there will be a button you can click to change a field. Click the button and select the Credits field. Then, set the Credits field equal to its current value minus the custom state’s value.

I am making a GTP-3 AI powered copywrting app that generates blog content and product descriptions based on user input. The value for gpt3-blog-response-total-tokens state is pulled from the the API response headers, and it’s definitely populating as its displayed on page:


Likewise, the Current User's Credits field exists and has a value:


Baffled… Could it be something to do with that thousand’s separator in the data credits field?

Ahaa! Thanks, I will try that now.

Yeeeees! :grinning:

Thanks @mikeloc that was a tricky one, I expected make changes to behave the same as other workflow and dynamic content assignments.

1 Like