Turn multiline input into individual entries in database

I want to turn MultiLine Input entries (one per line) into individual entries in a database.

I’ve read through countless posts on this forum about this and tried multiple methods with different Regex codes, ‘Split by:’ and Scheduling API workflow on a list. For some reason I just can’t seem to get any of them to achieve what I want.

I have included a basic illustration of what I’m trying to achieve. If anyone can help with this I’d massively appreciate it.

Kind Regards,

Calum

Split the multiline input into a list of texts.

Send that list of texts into a backend recursive workflow, and create a new thing in your database on each run of the workflow, for each of the texts in the list.

(Or you can run the workflow on the list directly)

Hi Adam,

Thanks for responding to my query.

I’ve spent some time watching YT videos for the recursive workflow. But I think where I’m now struggling is how to ‘split the multiline input into a list of texts’

I’ve tried ‘Split by:’ and then the ‘Enter’ button, and I’ve tried some Regex codes on this forum. How do you normally do it?

Kind Regards,

Calum

multiline input's value: split by and press the ‘enter’ key to split by a line break

Thanks for the quick response Adam.

Doesn’t seem to have done anything. The entries in the database still only one.

Do you see anything off in this schedule API workflow?

or anything in the recursive workflow?

Kind Regards,

Calum

I’m not sure what you mean by that… it WILL have split the single text into a list of texts (that’s what it does)… you can check your server logs, or look in the debugger to confirm that.

If things aren’t working as expected, then your issue must be elsewhere…

What is the (body) urls parameter supposed to take? (a comma delimited list of URLs?.. - if so you might need to use :join with , on the list you pass into that parameter to ensure it’s formatted correctly).

The (body) urls parameter is pulling from an API.

I input the urls into the multiline input, then the API scrapes the urls for ‘title’ and ‘price’. I think the issue I’m having is I need to transform the multiline input into “an array of strings” according to the API documentation, which is what I thought I was going to achieve with the ‘split by’.

I need to transform the multiline input into “an array of strings” according to the API documentation, which is what I thought I was going to achieve with the ‘split by’.

Ah… ok… not quite…

The API call body is just a string… (text)

when you use :split by on a text, it converts it into a list of texts

Say for example, you have a single text (i.e. tha value of a multiline input):

www.url1.com
www.url2.com
www.url3.com

Using :split by and pressing enter to set the delimiter to a line break, will split that single text into a list of texts:

www.url1.com
www.url2.com
www.url3.com

When you print that list into a text (as you are in the URL parameter of the API call) Bubble will separate each one with a comma and a space

So the actual text being input into your API will be (using the above example):

www.url1.com, www.url2.com, www.url3.com

Or… in context:

"batch": {
  "urls": [
    "www.url1.com, www.url2.com, www.url3.com"
   ],
  "concurrency": 1
}

which is incorrect… it should be:

"batch": {
  "urls": ["www.url1.com", "www.url2.com", "www.url3.com"],
  "concurrency": 1
}

or

"batch": {
  "urls": [
    "www.url1.com", 
    "www.url2.com", 
    "www.url3.com"
   ],
  "concurrency": 1
}

so, first you need to remove the quotes from outside the urls key in your JSON body (change "<urls>" to <urls>

Then, in the url parameter when making the api call you need to use:

MultilineInput ASINs's value: split by: format as text

Where, again, you split the input text by a linebreak…

Then, in the format as text operation, for each item you’ll need to show "This text"

And for the delimiter put a comma (and a space if you like, or a line break)

Ah that makes sense, as I compare my results to the API it is exactly what you said.

I feel like I’m nearly there but having followed your instructions, I’m now having issues with the API as I cannot re-initialize the call when in this format . Seems to only work with “” in the API. Getting this error…

I managed to get around the re-initialize error by adding " " in the parameter value though…
image

However, in the debugger I see the following, so it looks like it still doesn’t format it correctly…
image

no, you just need to make sure you include a valid array of strings inside the url dynamic parameter when initializing the call…

e.g.:

"www.mysite.com"

However, in the debugger I see the following, so it looks like it still doesn’t format it correctly…

That looks right to me (it’s exactly what you’d expect to see… i.e. a list of texts)

Aaah I missed one little piece!

I used This Text and not “This Text”. That’s it!! Job done!!

Thanks Adam, as always you’re a true legend! Much appreciated.

1 Like

Glad you got it working :slight_smile:

1 Like

I make a new solution for this problem sur you can take a look , in fact i want to know your option about solution based on what you say but without using backend workflow or APIS
SOLUTION IS :


When he click → set two states one for list of text and other counter to save count of list of text


this condition will turn on when counter is more 0 every time he will decrease counter by one and save a new record in database each time till counter is 0

demo : tutorial_bubble

Result