Get sub-tasks for a given task in Project Online CSOM
-
16-01-2021 - |
Frage
I m trying to get all tasks, which have given task as a parent using CSOM:
projContext.Load(tasks, c => c.Where(t => t.Parent.Id == parentId));
Here projContext
is a valid context and parentId
is the Id of a valid task.
I get error:
[Microsoft.SharePoint.Client.ServerException] {"Unknown Error"} at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream) at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse() at Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder sb) at Microsoft.SharePoint.Client.ClientRequest.ExecuteQuery()
at Microsoft.SharePoint.Client.ClientRuntimeContext.ExecuteQuery()
at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
What is wrong? How to do it correctly? Thank you.
Lösung
Try changing the query to this: projContext.Load(tasks, c => c.Where(t => t.Parent != null && t.Parent.Id == parentId));