Can't add items to list without backend workflow?

Hi,

I am making a simple task management app. There are tasks, and sub-tasks (I have created data types for both, and tasks contain a list of sub-tasks.

When I click save, I want the following to happen:

  1. Task is created
  2. Multiple Sub-Tasks are created
  3. Those sub-tasks are added to the task.

To create a list of sub-tasks in a single step, I use a backend workflow. So the steps are:

  1. A Task is created
  2. A backend workflow is run on a list of texts, each text is a sub-task
  3. in the backend workflow Each subtask is given a “Parent Task ID”, which is the unique ID of the task just created.
  4. Back in the main workflow, I add a list of subtasks to a Task’s Subtasks, filtered for those that share the unique id.

Expected result: the sub-tasks are added to the task, I can see I line item in the database with the task and with the sub-task texts listed in the Sub-tasks column.

Actual result: the task is created, and there is a line item in the database for this, as are the subtasks. But the subtasks are not added to the task.

I thought it was the case that the unique id wasn’t matching, but when I do the step-by-step, it was clear that bubble does see the list I want to add. It just isn’t adding it.

Any thoughts appreciated.

Sounds overly complicated…

(All in your frontend workflow) after the creation of the sub-task, just do Make changes to a thing then pick your task, then change the field “Sub-Tasks” and do add Result of [your Create a Sub-task step]

As you’ve discovered, doing things this way won’t work, as the front end action will be trying to add the things to the list before they’ve been created on the backend….

The simplest (but not the only) way to solve the issue is just to add the newly created thing to the parent thing’s list in the same (backend) workflow you’re using to create it.

Thank you! That solved it!

So what does bubble essentially do front end tasks first before creating them on the backend?
I had thought it did front end and backend tasks in the order shown in the frontend workflow.

I had thought it did front end and backend tasks in the order shown in the frontend workflow.

No… if you trigger a backend workflow from the front end, the backend workflow will be triggered as soon as the workflow runs… The front end workflow won’t wait until the backend workflow has completed to continue…

As a general rule, don’t expect workflow actions to necessarily happen in the order they appear in the workflow editor… although they should trigger in order, actions don’t generally wait for previous actions to complete before running (unless you’ve specifically set things up that way), so certain actions may complete before others even if they were triggered after them in the workflow (depending on the action of course).

There are plenty of forum posts, as well as a detailed explanation in the Bubble manual, about the order workflow actions run in, so it’s well worth taking some time to familiarize yourself with how they work, to avoid any misunderstandings that might slow you down in your development…

The Basics - Bubble Docs

3 Likes

Thank you! Very helpful - will check out.

1 Like