I have a Sharepoint 2013 Tasks App which I am accessing using CSOM. It contains SubTasks. I would like firstly (1) to get the Tasks excluding the SubTasks, and then (2) when I get a Task, to get it's SubTasks.
(1) After looking in a Task ListItem I noticed that SubTasks have a ParentId field that lists the lookup value of their parent task. So I thought to get only the top level tasks I'd get all tasks where the ParentId is empty. I tried:
List list = context.Web.Lists.GetByTitle(TaskListTitle);
CamlQuery query = new CamlQuery();
query.ViewXml =
@"<View>
<Query>
<Where>
<IsNull><FieldRef Name='ParentId' /></IsNull>
</Where>
</Query>
</View>";
ListItemCollection items = list.GetItems(query);
But it returns the Server Exception "One or more field types are not installed properly. Go to the list settings page to delete these fields." As a temporary solution I have just returned all tasks and filtered on those, but when there will be many tasks and subtasks this query will become huge so I'm hoping to get something better.
(2) Moving on to my second objective (get all Subtasks for a specific parent Task). I having tried getting the subtasks by searching all tasks where the ParentId of a task equals the specific parent ID, but as well as also giving me the error I listed in (1), I'm hoping I can get SubTasks through the parent Task ListItem to avoid a second query. Is this possible?
Thanks
Edit: I also posted this question here.