How to save list as separate database entries?

Users can input multiple tags on the page. A custom state stores the tags as a list on the page. How do I then “split” the multiple tags as individual database entries?

User Journey:
Input Tag > Custom State stores the ‘Tags Created’ as a list > How to Save Tags to Database as individual items?

Any guidance is very much appreciated, thank you!

1 Like

Hi there, @alee004… this question comes up on a pretty regular basis, and the answer is to use a recursive backend workflow to iterate through the list of texts and create a new thing for each one. If you search the forum for recursive backend workflow, you should find plenty of content that can help you get down a good path.

Best…
Mike

Thanks for the tip, Mike!

1 Like

Err actually, do you know of alternative methods besides backend workflows? I’m trying to complete a bootcamp assignment, and my assignment states: " If you’re on a free plan, you can avoid duplicate workflows without using backend workflows by using reusable elements and custom events instead."

I’m trying to still achieve without using backend workflows (I’m on a free plan)

As Mike mentioned, the best way to approach this would be using a recursive backend workflow, however, if you were looking to build this purely on the front end, I may have a scrappy solution.

If you were to limit how many tags users can add (e.g. a limit of 5 or 10), you’d know what the maximum amount of tags are that could be created at once.

When a user clicks a button to create their tags, you could run a workflow that ‘creates a thing’ (single item) within your database.

Within this first step, you’ll create a new tag (data type of tag with a data field called something like ‘tag name’).

As you’ll only be able to create one thing at a time, you can start by referencing the list of tgas in your custom state, the item stored as ‘item #1’.

At this point, we’ve only created one tag, so we’ll need to build some additional steps in the workflow to create the remaining options.

Duplicate the first step in your workflow, then update the ‘item #’ to be ‘item #2’. This will then create a new tag for the second item in your list.

Note: In some cases, a user might only create one tag, so you’ll need to create a condition on this workflow step that only allows it to run if the list of tags in your custom state is equal to or greater than 2.

Now, at this point, we’ve created two tags. In order to create a third, we’ll duplicate the same workflow step, but of course, we’ll need to update the item number, as well as the condition.

You’ll need to replicate this action to meet the maximum number of tags that a user can add.

It’s certainly not the best way to approach this, but it should get the job done.

Hope this helps.

2 Likes

Use @keith 's plugin ListShifter and use the PROCESS LIST action

2 Likes

Excellent solve @lachlankirkwood1 ! Your thorough response is very much appreciated, thank you~