Auto-binding and summing values

Hi everyone,

I am trying to use auto-binding to save numeric values to my database.

My scenarios is:
I have three input fields (one for price, one for quantity and the last one for discount percentage) and they have auto-binding enabled.

Now I would like to add a fourth input which would display the total and save it automatically to my database (E.g. Total = (price* quantity) - (price * quantity/100* discount percentage) ).

Any ideas?

Thank you

Hi there @ljf
Yes, I have an idea… which is not to use autobinding. :frowning:
I played with it for ages and came to the conclusion it has all sorts of problems in real world use. I just avoid it completely.

Sorry to the the bearer of bad news…

Best wishes


I would try something like this. Create a custom event to calculate the total from your input values. This can be saved directly to the database in a make changes to a thing action.

Trigger this event when any of the three inputs has their value changed (and all three inputs have values).

Display the total from the database in your fourth input (or you can use a text element).

I agree with @antony though, that autobinding should be avoided where possible.

1 Like

Hi @antony and @louisadekoya,

Thank you very much for your answer.

The only reason why I have had to use auto-binding up to now is because those inputs are inside a repeating group. I have only one button, underneath the repeating group, which has to save everything to database.

Unfortunately there is no way when clicking this button to use “create a new thing…” and getting the values of the inputs, because they are inside the repeating group.

Am I right, or there is a better way?

Thank you

Hi @ljf… I have moved to putting a save button in each cell of the RG, and having a condition on it which makes it light up if data has changed which needs saving. A bit more work for the user, but much much more reliable in the way Bubble works.

Hi @antony,

Yes using this method is much more reliable but it does not fit my case. I was hoping that there was some workaround.

Thank you

Hi @ljf, I think I might have a solution for that. You can create an input, then this input should not be visible on page load. Initial value of this input should be whatever you want to save, then enable auto binding. This should work.

Hi @vansokip,

I don’t I fully grasp how to accomplish this.
This is the editor to explain better what I need:

Thank you

Hi @ljf, this is what I did, when the value of any of the three inputs change, you run a workflow to create the “total”, this is easily done using the expression, only that this time round you wont have to use the input’s value, because they’re already saved in the database (autobinding).


Hi @vansokip,

Thank you very much for your help. I think this solves my problem.

Hi @antony, could you explain a bit more what you mean by this. I have had great success implementing autobinding for certain functionality but was just wondering if I should be anticipating any sorts of problems that I may not have noticed yet by relying on it.

Hi there @ryanellman… sure.

The main issues I had were:

  1. Sometimes the value takes a while to update in the database if you have other things going on in a similar time frame. For me, this meant I could end up opening a popup, changing a value, closing and re-opening the popup, and I saw the old value as the database had not been updated.

  2. If you have values that depend on each other, things can get very confusing. So if X=A+B and Y=C+X, the way Y gets updated was not clear and sometimes seemed to be just wrong.

Hence I decided to move away from auto-binding as a generic way of saving things, and just use it here and there for very simple situations.

I hope that helps!


Thanks for your detailed response! I think auto binding will still perform well for the simpler use cases I have used them for but this provides some good context about potential limitations.