Bulk Operations
Last updated
Was this helpful?
Last updated
Was this helpful?
Bulk operations let you modify a chunk of data at once, in the Editor. While it can be undone with backups, this is a dangerous operation and should only be done when you need to modify production data at once.
Note: Bulk operations run client-side, so they depend on your browser window staying open and active. In other words, you need to keep the popup open for them to continue. If you are looking to modify a large amount of data, the most effective and reliable solution is to use instead.
To perform bulk actions on your data, you need to define API workflows that you will call from the Data tab, in the Editor. The process starts by enabling backend workflows in Settings > API, heading to the "Backend workflows" page of your app, and creating an API workflow that takes one parameter and does some action with it. If you are only planning to use this API workflow internally (e.g. for a bulk operation), it does not need to be exposed publicly. The parameter type should be the type of data you want to process. Such an API workflow should not take another parameter, as when the bulk operation is running; it will call this workflow with the thing as the only parameter.
To reiterate: you create the API workflow to act on one item of the list of things you want to iterate over. When you initiate the bulk operation from the Data tab, you'll be doing it on a custom view of a particular list of things, and Bubble will do the API workflow on every item of that list - individually.
Let's say you have an app with a type 'House', and a field 'unsold'. You realized afterwards that the unsold field should be set to yes for all houses, including the entries already created in the database. Here is what the necessary workflow will look like.
and here is what the action would do, modifying the house sent as a parameter.
Once you are done with this part, you can head to the Data Tab, App Data section and select a view that shows houses. Clicking on Bulk Operation will reveal the Bulk Operation Popup, which lets you define which entries you want to process, and which workflow should be used. You can process the entire view, or only select some entries in the table and run the workflow on these selected entries.
Note that this operation permanently modifies your data, and can take some time if you are processing thousands of entries.