Multiline input rows to database

Hi guys,

I need some help with some bubble logic. So I have multiline input and after user will put there his data(list of email), I want each line of it to add to the database.

So, the content of multiline input will look like this:
some_email@gmail.com
test_123@gmail.com
bubble.dev@gmail.com

customer_email@gmail.com
and after the user will click on the submit button, each line should be stored as new record on the database(each record with email field).

Any suggestions or ideas? Will appreciate any help.
Thanks!

Hello,

I’d suggest using a regex to turn the multiline input into a list of values. You can then call a scheduled api workflow on a list to write each of the list values into your database.

You can do that as follows:

  1. Create a multiline input with a button

  1. Turn on Workflow API and backend workflows in SettingsAPI.

  1. Create a backend workflow where you take in a key which represents the data you want to write to the database
  • In example case the key is called new_input and it’s text
  • The backend workflow iterates on each item in your list

  1. Create an action in that workflow where you write the value in step #3 into the database
  • In this example, we’re creating a new Input thing and setting the field Value to the new_input in step #3

  1. Create a workflow for the button in step #1 that calls the backend workflow. You can turn the multiline input’s value into a list by using the regex [^\n][^\n]*[^\n]* which separates values by a line break. You can use a different regex to separate based on commas or any other character you like.

Hope this helps!

4 Likes

Thanks so much for this! I followed your instructions and got “line 1, line 2, line 3…” as an entry into my database instead of 3 entries: “line 1”, “line 2”, “line3”…

Any ideas how I can make these separate rows?