Depending on the user type, some fields are shown or hidden.
Export button to CSV.
Currently I have multiple export buttons that are shown or hidden based on the user type. I think this is a clunky solution because when I add more user types I would have to create additional export buttons and make sure not to get lost.
Is there a way to export a repeating group exactly the way it is shown to a user without creating multiple export buttons?
My goal is to end up creating “yes/no” user fields to govern the way a repeating group fields are shown to its users and this is where my problem starts with export function.
The silence to your question should indicate to you that if you want to work in an environment where data is easy to get into and out of your system, then Bubble isn’t it. As a few people have written, if you stand back and look at a Bubble App, the best decision from a data perspective might be to not have your data reside in Bubble at all.
Accurately exporting data from a “joined” dataset (despite its essential use in application development) is almost impossible. Mainly because of the freedom allowed to you as a developer within the repeating group element. Hence, the good (flexibility) has come with some tragic consequences. The issue is that Bubble will not recognize the different data types within the repeating group as a part of single line and as a result the export transposes the list across and then down which results in an unusable mess.
There are a few approaches that I’ve used that can work.
You can use Python to extract the Bubble data from a page and turn it into a CSV. I have a customer that does this because I can’t give them the data they see on the screen in a file (I can’t believe how bad that sounds)!
You can export a page as a PDF and then import the PDF into Excel. This is about 95% accurate and requires less manual intervention than how most exports will work.
The last and worst option is to try copy and pasting the data from the screen, but I’ve found that the transposing issue persists and it usually requires a lot of fix up.
Create a whole new table that extracts data from other data types and merges them into one and then spits that data out - yep that is what some people have to do!!!
You could create an API Workflow that takes each row of your repeating group and writes it to a text field in a table called something like “Export Table” that simply has one field in it; the data. When you export it, you will have already limited each of the data points. I have not tried this but I just read someone else’s idea that made me think this might work.
Sorry the news is not better. This is a massive whole in the Bubble architecture and the longer Bubble stays quiet about it, the more of us will need to find solutions to a simple problem elsewhere.
I would really like for Bubble to take this seriously and solve the problem and just export what’s on the screen.
This is an old thread but since I found a solution I thought I’d add it. (It’s a bit hacky and uses elements that weren’t intend for this purpose - but it works in a pinch - this method worked as of 10/19/2023)
Add the Instant calculator Plugin to your app and put the instant calculator element in the repeating group. Instant Calculator Plugin | Bubble
Create a yes/no state on your page called hidecalc with a default state of yes (or any element that’s not the instant calculator)
Create a Conditional format on the Instant Calculator so that when the hidecalc state is yes, the instant calculator is not visible (Note: on the layout tab the element should still be visible on page load regardless the conditional format)
Create a new Data Type called “Temp Download” with fields for each item in a repeating group row you intend to download (i.e. if each row of your repeating group has first name and last name, you will need to fields in Temp Download)
Create a conditional format in your repeating group so that when hidecalc state is no the data source is the same data your currently have. (If your data source on the appearance tab is “Search for Mydata” - then the data source for the condition should be “Search for Mydata”) this step will seem redundant but its important.
Create a button for your users to click to download the repeating group data as a csv.
The workflow for the button should be as follows:
Step 1: Delete a list of things; type of things “Temp Download”; List to delete “Search for Temp Downloads”
Step 2: Set the state of hidecalc to “no”
Step 3: Add a 2000 ms pause
Step 4: Download data as CSV; type of data “Temp Download”; Data source “Search for Temp Downloads”
Step 5: Delete a list of things; type of things “Temp Download”; List to delete “Search for Temp Downloads”
Step 6: Set state of hidecalc to “Yes”
Create a workflow for instant calculator so that each time instant calculator completes a calculation it creates a new temp download where the items you want to download are equal to the current cell’s fields (i.e. when instant calculator finishes a calculation it creates a new temp download where “first name” = this cell’s first name and “last name” = this cell’s last name)
Why it works:
The button work flow makes sure you start with an empty data base in Temp Downloads. Then it changes the state of the Instate Calculator making it visible along with refreshing the data in the repeating group thus triggering the instant calculator’s workflow to populate “Temp Downloads” with all the items that load in your repeating group (instant calculator will trigger the workflow for each time it appears in the repeating group, it’s almost like a for loop). The system then waits two seconds while the instant calculator does its thing. After that it downloads all the newly created items in “Temp Downloads”. Once downloaded it clears out the “Temp Downloads” database and hides the instant calculator so it won’t constantly be doing calculations every time your repeating group changes and you don’t want to download data.
Commentary:
Because you are actively creating and deleting data entries each time the workflow runs there could be some unintended consequences if multiple users run it at the exact same time and I would not use this method in a public app with heavy usage. This method is more suited for Admin type app users and internal apps: cases where multiple people are unlikely to be running the workflow at the same time.
Also - the privacy settings on “Temp Downloads” should be set to the same as the original data set. Otherwise you are temporarily taking what could be private data, making it public for 2-3 seconds, and then deleting it.