Child/parent/grandparent relationships

Hi All

I am trying to create automations within a task board.

Essentially i’m creating a parent/child relationship - Task B is dependent on Task A doing something. For example, Task B status will update to in progress when Task A status is changed to complete.

To extend this I have created a copy list of tasks function.

If a user copies a list of tasks, and a child task is in the list but not the parent, I ask if the parent should also be copied.

The issue i have is when a parent is introduced to the list of tasks to copy, I also want to add the grand parent task to the list if the parent task has a parent, and continue this cycle until all tasks in the list to copy include their parent tasks.

At the moment I am achieving the outcome by provisioning a number of states that collect the next level of parent tasks but this is not ideal for obvious reasons.

The next issue is how to copy the list of tasks in the right order so a copy of a parent task is created before the child.

Has anyone that has built a solution to solve this type of requirement got any tips?

Thanks in advance!

Are these 3 different data types, or are they nested in a way where it’s one data type, with it’s parent also being the same data type?

Sounds like database triggers and recursive workflows will be helpful for you.

Also why so much copying of lists across multiple things? Sounds like a lot of CPU usage

Thanks for the response. Yes, all the same things.

Its actually 1 list that i want to copy, the issue is compiling the list to be reflective.

List is list of tasks, then add any parent tasks that do not already exist in the list, then add grand parent tasks if they do not already exist in the list, etc…

I’m like 80% sure combining lists won’t add duplicate items, it will only keep the first instance of it. So you can use the merged with operator to combine lists together. Is there a specific order you’re trying to put them in after the merge?

Also your list copy action, does that always happen on the child, or does it happen only on grandparent?

Thanks for the follow up.

Yes, I’ll try and explain things better.

I have created a task and task board feature with 4 status:

  • Backlog
  • Roadblock
  • In progress
  • Complete

I have also created a task automation feature so that users can automate task status update to in progress based on another task status updating to complete for example.

When a task is automated the child parent relationship is created.

Fields in the data model are:

  • dependcy task (parent)
  • list of dependent tasks (children of parent)

So when task B is automated it becomes child, I update Task Bs record by adding the parent, Task A, to dependency field. I then add task B to the list of dependent tasks on Task A record.

That is all fine.

Now i am adding a template feature so a user can copy a board and all the tasks on that board, and maintain their automations. This is also fine.

They can then, at a time they like, create a new board, and add the templated tasks to the new board.

To do this I am using schedule api on a list, but unless i use a larger interval like 5 seconds, the task records are not copying properly, and using a 5 second interval when someone is copying a template with 20 tasks is like waiting for the a dial up connection (if you’re old enough to know what thats like).

Whats more, is the order of tasks being copied becomes important as if a task is created that has a dependency (ie a child), and the dependency task (parent) has not already been copied, the automation data cannot populate ads the parent record does not yet exist. For example, task A is parent, and Task B is child of task A. If we copy both tasks, and task B is copied first, the copy of task A does not exist and so the new task will not be automated as the dependency field will be empty.

I’m looking into recurring api, but at this point haven’t been able to work out how to run it on the list of tasks i need it to run on. I don’t need a set frequency, its a one off, whenever a user needs the feature.

What if you add a field to a task called duplicatedFrom.

Now you have few workflows one is a regular workflow, it creates a new task, with all the details of the original task (other then the parent), and it fill in the duplicatedFrom field

The second is a backend flow, that triggers every time a new task is created.
The tasks does checks id the DuplicatedFrom has a parent, if it does it

  1. Creates a new (parent)task and copies the data from the duplicatedFrom parent task
  2. adds the duplicatedFrom value to the new parent tasks
  3. adds the new parent to the task that triggered the workflow…

The creation of the new parent should trigger the workflow again until there are no more parents… and of course you can end the workflow immediately if duplicatedFrom is empty…

Seems like maybe you need to make some index fields to maintain the structure when copied. When you populate the parent as [unique id] or task reference, that link will be broken when you copy everything over. Instead you can make the first level of task (with no parents) 1, and then its child is level 2 and so on using parent tasks level +1 you could go on forever like that. Then, you make a mother parent field that holds the unique id of the first level task as text. use this for all subordinate tasks. Then when you make a copy using create a new thing, you set that field the value of the first created task for all of the subtasks, but they will still have the level fields copied to hold the structure.

Thanks Elad. I am using a field to reference the “old task” already.

The parent tasks will already exist in the list being sent to the api workflow.

If I have understood your suggestion, I think it would create duplicate parent tasks, ie. create one from the list sent to the api workflow, then another when the database trigger runs…

Thanks Teka Teki. I’m not sure I understand your suggestion?

:joy: Yep I know that feeling…

What you need is when they hit the copy button you need a recursive backend workflow, where it essentially goes down the chain and finds the most child entry, and works its way up. Do you feel like DMing me the editor link with view (or edit) permissions so I can take a look? Or make a copy I can look at? To test it with backend working it needs to be on a paid plan

Yup, so I thought you were stuggling with copying the tree of tasks and keeping them in the same structure… my suggestion is to not rely only on linking to the parent task, but to also have another sequentially numbered field that would ensure that even if you change the child-parent relation, the position of each duplicated task would remain the same as the original because they are sorted by the sequential id field.