MathJS result not posting to DB

My problem is in getting the database to log a value from a MathJS evaluation.

This page is what we are working with. The operator enters a name, table number from dropdown, seat from dropdown, then configures the Dealer Add-on, Rebuy, and Add-on numbers before hitting “Enter player”

The workflow for that looks like this:

However when we go look at the entry in the DB “Spent” is empty.
I know the equation is working correctly as it shows in the debugger like this:

So I’m really just unsure what I have configured incorrectly?

Thanks for any help!

Not sure how this particular plugin works, but looks like you’re referencing the plugin element’s state.

  1. I’d check if the action Evaluate Expression returns the result. Then you can set the value on your 2nd Action as step 1’s result
  2. I’d look for an event from the same plugin that triggers when the result is complete. The result evaluation might be async and that’s why it doesn’t show up on your next action.
    Else, you can try adding a pause before next action before the 2nd action - this isn’t as reliable as using the plugin’s event though.

I’ve never used that plugin but it’s quite likely that it doesn’t operate synchronously, so that output value isn’t available in the second workflow step.

But why bother using it anyway? You can do that math in a regular Bubble expression. (Or series of expressions setting the value of a custom state. Those actions ARE synchronous.)

BTW, in case you didn’t know, parentheses are available in Bubble expressions via this:

Yes, this lets you do a lot more complex logic and calculations now.
Here’s a plugin that might help in case you think that doesn’t quite do it: Math Expression Formula Calculator Plugin | Bubble

Thanks for the responses so far. While I was waiting for some responses I tried changing the workflow such that It does the math evaluation and then stores that in a custom state like this:

Then it goes to create the entry in the DB:

You can see here that it does have the correct value of 110 in the “spent” column. However it does not appear in the DB.

Additionally, before this version, I had bubble doing the math operation and I had the same result.
I’m admittedly amateur with bubble but so far everything I’m seeing is telling me there is some kind of disconnect at the DB level?
The data type for “Spent” is set to be a number so I really just don’t understand what is going on here.

You really should reread my answer.

Which part do you think I am misunderstanding exactly?

That the output value from that plugin isn’t available in the second workflow step because it’s asynchronous. It doesn’t matter what the next workflow step is, the value is simply not available yet.

If that is true why does the next step show the value as being entered? “110” is shown as being entered, but it is not entered. Additionally, as I said, in a previous version I did not use this plugin and I had bubble doing the calculation and got the same result.

Because the inspector is running AFTER the workflow. By the time you inspect it, the value is there. And I just looked at the code for Mathjs Local. It’s asynchronous.

1 Like

Exactly which mathjs plugin are you using? There are many.

(Again, not that you need it in this context.)

I’m not sure why the link to the plugin page doesnt work but it’s this one.

I’m going to try going back to having bubble to the calculation and see what I get.

It’ll work just fine and you won’t be loading a (useless) third party library, so ultimately faster.

Also, that API call version is bunk. No use that.