Trouble populating a custom state list of things

I’m building an app that has a hierarchical list. All items of type ‘task’ have a ‘parent task’ of type ‘task’. I then display them in 2 tier repeating group. Any task without a parent is a top node, and sub nodes fall under. I have it set up so I can drill down the hierarchy by updating the state variable “parent task” on the item display RG datasource. What I’m trying to do is build a breadcrumb nav at the top with a horizontal repeating group so I can climb back up the hierarchy. I have the breadcrumb nav repeating group (RG Nav) datasource set to a state called “task parents” on the RG with ‘list’ checked.

The heart of the matter:
I’m trying to build a list of tasks that contains the selected task and its parent and that parent’s parent… up the line until the parent field is blank to use as my datasource for my breadcrumb RG. To get the level currently displayed, I have a workflow that sets the datasource state RG Nav task parents = RG Nav’s task parents:plus item RG display task parent.
To get the next parent I try to set the state value of RG Nav’ parent item list to RG Nav task parents:plus item RG Nav task parents:last item’s parent. I can see in the debugger that it gets the parent, and adds it to the list, but then somehow deletes the child at the very end.
Any ideas? What am I doing wrong? Is there a better way of populating this list?

If I got this to work, I was going to bounce a loop back and forth between two custom workflows until ‘task parent is empty’

Welcome to the community!

I am not sure I follow.

But I would like to submit that when custom states fall short … you can use elements. For single values use groups and for multiple values repeating groups do the job. The advantage these have over custom states is that you can use conditionality, constrain the values, and other operators to handle the data.

Place them in a popup that you never open and name them as intuitively as possible. Example: an rg holding tasks could be called data-tasks or var-tasks. This way you can find them easier in the expressions inputs.

Do not know if this helps but maybe it can spark some ideas :+1:t2:

Thanks for the reply Carlos and the welcome! You did spark an idea.

I created a second custom state (called “one task up”) and split the process up. In order to add the parent task to the list I have to set custom state value “one task up” to Parent Task List:last item’s Parent and then in a second step set the list to Parent Task List:plus item ‘one task up’.

In the documentation it says this about the ‘:plus item’ operator:
“This operation adds an item to a list of things. It returns a new list with the original list plus the new item. If the new item is already in the list, it will not be added.”
All I can think is that the reference to the ‘last item’ somehow keeps it from being added in one step.

This topic was automatically closed after 70 days. New replies are no longer allowed.