Basic of showing DB data on Bubble - repeating group

Hi all, I’m new on Bubble and I have some basic doubt about showing data on page.

I have many pages on my app that show tables of data, mainly payments and invoice in many way (grouped, currency converted, etc.)

On every page I do the right formulas to show for example (converted amount at current exchange rate, discount if paid today, etc.). I do that directly on text object and on every page I do the same formulas.

Is there a way to have those data calculated once and sent to the page as a repeating group so that I don’t have to do that on every page?
Formulas are every time the same and in some pages I used only some of that.

I tried a background workflow with return data but I don’t know how to:

  • send back a repeating group
  • catch back the data on the page (i don’t know why but I can’t get back the return
    data from a simple background workflow

Thank you!

Welcome!

As far as I understand, you’re currently doing calculations on the fly, and want to store them in the database. For example, if a payment is in GBP, you want to show it as USD.

When the payment is created, do the currency conversion and save the converted USD amount to a usdTotal field on the payment data type (note this method would not be scaleable if you want to support viewing in multiple currencies - in that case you’d have another Currency Conversion data type which has an Amount and a Currency, and store the converted amounts as a list on the payment). I would set this up using a backend trigger (Only when Payment now’s total is not Payment before change’s total → get currency conversion from API → save to Payment now).

You could also do this, but it may be slow and more expensive in terms of WU. You’d create a backend workflow that takes relevant parameters, do what you want, then Return data from API. Call that backend workflow from the API Connector or App Connector (so set up an API call to your own app).

The problem is that exchange rates changes every seconds and in this way the stored conversion will be old soon. That is why I need something done on the fly.

Maybe I could do it every time the user requests the page with converted amount to reduce total WU

I need only one currency convertion (EUR) so this is not a problem

About WU it would be more expensive to :

  • retrieve every time the repating group from a backgroudworkflow/api or
  • update conversion on DB every time the user (or background offline workflow) request the data and then retreive repeating group on page/workflow?
    (in SQL I would have solved with a joined view for example)

With both method I could solve my main issue that is to group and sum multicurrency payments. Is there any other way to do that?

Thank you!

Oh, I thought that you were only doing it once (as for a Payment, the currency conversion rate is determined at the point of purchase). i.e, you need to know what USD → EUR was on the date the payment was made - it doesn’t matter how it changed since then.

Just do it on the fly.

Depends on your API costs, but I’d just go with the simplest solution which is to calculate it from the repeating group using a data API call.

You are right I missed to tell you that are deferred payment to be done days/months in the future

About API cost you mean my internal API (so WU costs) or currency external API (so EUR costs)?

If it is the 2nd it is not an issue because I refresh it every day on db so the cost is allways the same and for all users/payments.

I don’t understand what will be cheaper for you in terms of WU between:

Thank you again for your help!