Templates Plugins Courses

Using Math.jjs tocalculate expression

I am trying to make a list of changes using the workflow in bubble.

I want to achieve what is on this screenshot:

So basically calculate the variable :

1 HardwareQtyinWarehouseTotal Stock ( A)

and substract it from the value of:

  1. InputQTY (B) * Another Number ( C)

So I need: A - (B*C)

However when I execute it, Bubble does:

(A-B) * C

When I try to use the MathjS A’s Evaluate(B*C) so I substract it from (A ) It does not give me the option of Input QTY etc after the expression as in screenshot:

Is there a way around it?

Hi @purchases,

Thanks for reaching out.

You can easily accomplish this with the help of our plugin, because Bubble is not that good with BEDMAS.

The only thing you need to do is setting the formula properly.

In this case, let’s say that A, B and C are 3 different input elements. The formula will look like this (if you display the result in a Text):

image

Where MathJS Multiply Result is the multiply operation between B and C:

So, to showcase, this is how it looks like:

Hope it helps!

Best,
Alex

Hi Alex that works ok for static expressions but how can put it inside search results?

May I explain a bit more in detail.

Let’s say I repair mobile phones and I want to keep a record of how many screws I have in the warehouse.
So I have one table that lists the screw names and qty in stock:

Screen Shot 2021-04-27 at 20.56.52

Also I have a table that states how many screws are used per phone:
Screen Shot 2021-04-27 at 21.01.04

Finally I have a table that records mobile phone sales:
Screen Shot 2021-04-27 at 21.02.10

So now on 24/01/21 I want to calculate the stock of screws I have .
So I have sold two HTC Phones.

Now I need to make a Workflow as such:

  1. Make changes to a list of Things
  2. Search COMPONENTS-LIST-TABLE
    With Constraints: List Item being part of HTC Phone ( taken from second table PRODUCTS-LIST TABLE - another search) and make this calculation:

List Item’s"QTY In Warehouse" = Existing QTY in Warehouse - ( QTY Required Per Item * QTY of Phones SoLD )

So on the 24/01/21 ~If I would run the workflow I could see that the total stock of 15mm screws were. 2000 - ( 5 screws per phone * 2 Phones sold ) = 1990 in stock left.

Then the same workflow will carry on and update the next screw used in that day and it would be the 20mm screws.

Makes sense? Can I do that with Math.js basically use it inside the same workflow( not separate )?

Hi @purchases,

Thanks for feedback. Sorry but custom implementations help are beyond our support services, unfortunately. The plugin works as is, and you can easily implement it in any workflow you prefer, based on your app requirements. There are no limitations in terms of when to use the calculation, but just make sure to perform it properly.

Hope it helps.

Best,
Alex