Forum Academy Marketplace Showcase Pricing Features

Add data into Bubble table within Javascript

Hi All,

First of all, I would like to say Thank you to @mishav for creating Toolbox plugin. This is very helpful for working with Javascript in Bubble.

Currently, I’m struggling of list and Bubble table for query and return what I want.

I have Bubble table define as following:
| company | plan | coverage | annual payment |

In Javascript, I will have a number ex. 2,100,000. For this number I will spit based on coverage in Bubble table and return with possible of plan to offer.

2,100,000 = 100,000+100,000+200,000+200,000+500,000+1,000,000
This mean to offer 2,100,000 coverage, I have to offer 4 plans (100,000 x 2 plans, 200,000 x 2 plans, 500,000 x 1 plan and 1,000,000 x 1 plan)

Javascript to Bubble functions, I return with 2 lists,
item 1. list of number coverage (ex. 100,000 , 100,000 , 200,000 , 200,000 , 500,000 , 1,000,000 )
item 2. list of number of duplicate in item 1. ( ex. 2 , 2 , 1, 1 )

Previously, I tried to return 2 dimensional array ex. [ [100000,2] , [200000,2] , [500000,1] , [1000000,1] ]. However, this is not seem to work.

So, what I’m trying to do now is if I create a new Bubble table (with 2 columns 1. coverage 2 offer ) and put it inside Javascript instead. How can I do it in Javascript ?

Any help to solve this, very appreciated. :slight_smile: :slight_smile: :blush:

Hi @saycheeseins, good you are finding the plugin useful.

Can you clarify:

What you are storing? For example:

| company | plan | coverage | annual payment |
| U Work 4 Me | World Domination | 200,000 | 0.88 |
| U Work 4 Me | Unda A Rok | 100,000 | 0.08 |

What data do you want to calculate from the stored data?

What you want to display?

Some pointers:

  • Bubble can store duplicate values as long as they are fields in different rows (things).

  • A thing could store two fields (coverage, number of duplicates), then you can search for a list of those things, to get your 2 dimensional array.

  • Once you separate out the field values into a list (search for thing’s coverage), you get a list of single values that can contain duplicates until you do a list operation like add item.

  • You can use arrays of arrays in javascript structures, and display them in for example a HTML with styling.

  • Pulling the values back into Bubble would generally need to flatten a complex structure into a list of single values.

Good luck!

Hi @mishav. Thank you for your pointers. It works now. very appreciated ! :sunny: :smile: :blush: