Modify API data in plugin or modifying returned data in workflow

Bubble doesn’t support parentheses in dynamic expressions, so what you are building up is a mix of text and dynamic expressions, the parentheses being in the text part.

It looks like the Math.js plugin is giving you a small text field to work in, which makes it harder to navigate than a long text field, because once it sees the dynamic expression, it doesn’t let you click outside it to add text.

So the trick is to add the surrounding text first:
()

Then put the cursor inside the text, (between the parentheses), and choose dynamic text, click in the Bubble pieces …
(Current Page DiviSystem’s Copper * 0.1)

Then you can edit the text on either side, putting in more text or dynamic expressions where you want them, so long as there is text on the edge you can keep adding more.

What Bubble will do is evaluate the dynamic expressions, concatenate the results with the text bits, and send the whole lot as a text to the plugin.

Consider a text field as display-only … you can retrieve the value with javascript, but that would be a hacky workaround.

1 Like

Ok, that is finicky, but I got it. I mean I was able to create the expression… but it evaluated incorrectly.

29%20PM 18%20PM

The sum evaluated to 604.8, but the correct value is 388 or so

The expression in the Math element evaluates to:

22.5 + 47.7 + 96 + 66 + 150

Or 382.2 if I’ve punched the numbers correctly. (and I have as that’s the sum of the total divi in tier column)

Are you really displaying the value of the math.js element, or are you displaying something else?

I really and truly am. And yes, 382 (this number changes as each time I run this, the number of masternodes changes) is the number I am expecting and not getting

Hmmm… math.js evaluates just like JavaScript I think. So, you don’t need the parens here. Dupe your math.js element, clear the contents, rebuild the expression sans parens and see what THAT evaluates as.

Thats how I had it to start with. See comment 7 hours ago. It was far worse

Just do it as s couple of workflow steps then. This simply isn’t hard.

I went a different way. I just created states for each product in the main workflow. Then printed the states in the text fields for each tier. Then I added the states for the sum. Or maybe thats what you meant.

Works.

That’s exactly what I meant.

Note you could also just use a single state (reuse in multiple steps):

state = thing1 * mult1
state = thing2 * mult2 + state
state = thing3 * mult3 + state

etc.

As optimizations go that’s not going to be wildly different than how you did it. The main point is to get to the right answer! :slight_smile:

Thanks for the help today. I appreciate it.

1 Like