0

I have a task item and i want to get all its subtasks including its subsubtasks recursively, preferably via CSOM, but I appreciate any hint to how this could be done. I tried a caml query that queries the ParentID of the task. However the following query returns only the direct nested subtasks (1 level).

<Query> <Where> <Eq> <FieldRef Name="ParentID" /> <Value Type="Counter">1</Value> </Eq> </Where> </Query>

Adding <View Scope="RecursiveAll"> to the query didn't change anything either.

Elie Fares
  • 11
  • 2

1 Answers1

0

There isn't going to be any way for you do to that in CAML; it's just not a robust enough language to execute such a query.

You'll either need to pull down all of the data in the list, and do the query in memory, or you'll need to get all of the direct decedents of the node in a query, perform another query to get all nodes one level down, and so on, until you get no more results. Whether it'll be better to pull down a lot of data that you don't need, or to perform many round trips to get the data, is going to depend on just how much data you have, and how deep you expect your trees to go.

<View Scope="RecursiveAll"> is there to indicate that items in all folders should be queried, not just the root (or specified) folder. Your items aren't in folders, so this isn't affecting your query.

Servy
  • 202,030
  • 26
  • 332
  • 449