Hi guys,
Firstly, I want to thank you all for your answers and support up to now. This community has been fundamental in helping me launch our new platform, website & app & I cannot thank you enough.
My latest issue:
So I have a database of items (in this case eSIMs) in bubble which i am displaying in a repeating group/table.
I have a field in each row/item called “data usage” which makes an API call using the item/eSIMs ICCID/identifier to GET any data plans and usage associated with that item/esim.
The response I get from the API call is below. (Example):
{
“iccid”: “8920400000006221466”,
“plans”: [
{
“id”: “hXcNwv2J1W3A”,
“end_time”: “2023-06-10 12:34:00”,
“start_time”: “2023-06-07 11:16:08”,
“date_activated”: “2023-06-10 12:34:00”,
“network_status”: “NOT_ACTIVE”,
“data_quota_bytes”: 1073741824,
“countries_enabled”: [
“CAN”
],
“data_bytes_remaining”: 1073741824
},
{
“id”: “vH64lnwTxG9Q”,
“end_time”: “2023-07-12 11:20:01”,
“start_time”: “2023-06-07 11:18:40”,
“date_activated”: “2023-06-12 11:20:01”,
“network_status”: “NOT_ACTIVE”,
“data_quota_bytes”: 1073741824,
“countries_enabled”: [
“USA”,
“CAN”
],
“data_bytes_remaining”: 1073741824
}
],
“result”: 1,
“status”: 200,
“message”: “”,
“request_id”: “JdwRN7lk1NgYm20iQBAyAKPS”,
“developer_message”: “”
}
So as we can see in this response example…an eSIM/item may have multiple data plans. This is returned in the api response.
Heres the problem/challenge i am struggling with
So currently, we have an expression in the text field in the repeating group that makes the api call to get this response. But currently only selects the first item/data plan and calculates the usage on that single plan. But of course, some eSIMs may have multiple data plans therefore I am not capturing/displaying the total usage on an eSIM/item, only the first item from the API response/data plans.
So I am thinking I need to use a SUM expression to sum up the values from ALL data plans returned in the response which will then display the TOTAL data usage/figure in my repeating group.
To further complicate matters…their api response doesnt tell us the data usage. it only tells us the data quota (the data allowance/bundle in bytes) and the data remaining (how much data is left in that plan, in bytes) so I am having to take the quota, minus the remaining data to get the total data used & i am also having to divide the figure accordingly to get the megaybte or gigabyte total usage.
What expression should I use to do this?
Thanks,
Nick