Subtask sections

subtasks
sections

#1

Hi there,
I’ve been able to read ‘sections’ out of tasks for a project by interrogating the memberships, but when I try to do the same for a subtask, the memberships comes back empty, (even though it is in a section in the subtask).
Is there another way I can read sections on subtasks?


#2

A subtask is a task, so you should basically get the same result. Aren’t you trying somehow to read the task and subtask at the same time?

Bastien
Asana Certified Pro, consultant, author and developer


#3

That was my initial thought, but even if I fetch the subask, like a task, I’m still not getting the memberships populated.


#4

That sounds weird indeed. @Diakoptis any idea?


#5

Hey,

memberships in subtask is empty because a task (or subtask) get memberships when is “homed” in a project. You can find the subtask-sections in a task by fetching the subtasks and find out that the last character is “:”.

No other idea at the moment. Maybe @Phil_Seeman is more appropriate because he is playing with subtasks order lately :wink:


#6

@Diakoptis so a subtask under a “subtask section” won’t be seen as part of a “section” is that correct?


#7

Yeap.

{
  "data" : {
    "id" : 747945712217043,
    "memberships" : [ ],
    "name" : "Subtask",
    "parent" : {
      "id" : 747945712217041,
      "name" : "Task"
    }
  }
}

#8

The only way I know of to find out what section a subtask is in, would be to walk up its parent tree until you find a task with a “:” as its last character (or you hit a Parent Id of 0 in which case the subtask is not in a section).


#9

Thanks @Diakoptis, @Phil_Seeman, Bastien_Siebman, - Unfortunately no joy. When I walk the tree from the subtask to it’s parent, the parent doesn’t have a “:” in it’s name, (it’s just a task name, not the section name). And when I look at the memberships for the parent, it just has the section details that the parent belongs to, not the subtask’s section.

Any other ideas?


#10

Now I’m confused - you’re saying the subtask is in a section also? And that’s different than its parent’s section?

Can you post a screenshot of the scenario you’re working with? I think we need to see your use case.


#11

Hi @Phil_Seeman - Apologies for the confusion. In the example screenshots (1 below and 1 in subsequent post), I want to capture the relationship between sub task, “Here is a subtask in a section” and it’s section, “Here is a section in a task:” But the responses from the API in the other screenshot don’t seem to allow it. Any guidance welcome. Many thanks.


#12

Here is the other screenshot.


#13

Ah, OK, got it now!

A membership represents a membership in a project. From your screenshots, it looks like the subtasks “Here is a section in a task:” and “Here is a subtask in a section” are not assigned to the TestTimeline project (or any project for that matter). Therefore they can’t have any memberships, as illustrated in the empty memberships array in the bottom part of your second screenshot.

I’ll bet if you assigned those subtasks to the project, you would then see the membership info you were looking for. Try it and let us know if you do see the membership info in that case.

Does this all make sense?

Now of course you might say, “yeah but if I assign them to the project, then those subtasks show up in the project’s task list and I don’t want that!” In that case, you won’t be able to use memberships to identify the subtask’s section. You can then use the alternative, which is to get all of the subtasks in the task and walk, not up a parent tree but instead walk backward up the subtasks list, looking for an entry that ends with a “:”. When you get a list of subtasks, they are guaranteed to be returned in the order that they appear in the UI, so you’re therefore able to walk up the list looking for a task’s section.


#14

Thanks @Phil_Seeman - I’ll give the alternative a shot. If you don’t hear back - it’s all good. Many thanks, Damien.


#15

Your alternative would be to get all subtasks, extract the ones with a colon “:” and get the section yourself :sweat_smile: