Reading all sub tasks of a Summary task using CSOM

Hi Readers,

Thanks for reading.

I’m gonna show you the CSOM code to read the “Sub Tasks” for a given Summary task.

Below code snippet reads the sub tasks for the given summary tasks.

string phaseTask="<summary task name>or <id>>" ;

var draftTaskCollection = context.LoadQuery(draft.Tasks.Include(t=>t.Name, t=>t.Id, t=>t.Parent, t=>t.Start, t =>t.Duration, t=>t.IsSummary) 
							.Where(k => k.Parent != null && k.Parent.Name == phaseTask) //if its Id, then use k.Parent.Id 
if (draftTaskCollection.Any()) 
	foreach (var task in draftTaskCollection) 
		// read the properties that you have loaded in the above query. 


In the above sinppet Just pay attention at the below line.

.Where(k => k.Parent != null && k.Parent.Name == phaseTask)

In the next blog will discuss about reading theĀ  “All subtasks & Sub summary tasks” of a given phase(summary) task.

Thanks !