Getting Tasks for a single Project (On Prem, Web API, C#)
I'm only seeing 8 out of 139 Tasks being returned. They are all IsSummaryTask = true.
Image attached showing ModelProperties.How do I get the other 131 tasks?
Thanks,
G
-
So I have found that I can get the task data that I need for a project using Task.GetByProject() in the API. It just means making a 2nd call to the API. The Project.Get method tells me that there are 139 Tasks, but only shows me the ones marked as Summary Tasks. Weird.
:-)
0 -
Good morning Gary,
If you look at the Summary Task collection, do you see the children tasks under them? Remember, you can also use the Project.Search method to return results more refined with specific params.
Seems like you're very close to retrieving the data that you need.
Thank you,
Robert
0 -
Robert,
I'm using the Web API, not the application. All I see are the 8 summary tasks.
G
0 -
Gary,
I understand that you're using the Web API (client). Have you used the Project.Search method available? You'll be able to filter more effectively and return the data you want.
Without seeing your data within PI, I won't be able to tell you if the data being returned is correct or not.
I'll replicate a project with summary tasks and child tasks within them and follow-up with my findings.
Thanks,
Robert
0 -
Gary,
I was able to create a project with two Top Level Summary Tasks and added child tasks within the summary tasks (see screenshot).
I then used the Task.GetByProject and successfully received the JSON response with all the tasks (children and summary tasks).
Results:
[
{
"SummaryTask_Id": null,
"Project_Id": "180d9cb5-068a-423c-939d-e090d6f39cb6",
"IsSummaryTask": true,
"DurationSeconds": 0,
"WorkSeconds": 0,
"StartDateTimeUTC": "2018-07-10T15:00:00Z",
"EndDateTimeUTC": "2018-07-10T15:00:00Z",
"WorkPercentComplete": 0.00,
"WorkPercentCompleteType_Id": "6b1ed2b6-881a-4ea8-affc-8ca182a594e3",
"CustomFieldValue_Id": "c8e7b31d-66ca-40a0-b559-203e69b5301a",
"IsActive": true,
"Name": "Summary Task #1",
"UrlFull": "http://dev33.sandbox.projectinsight.net/ProjectInsight.WebApp/task/5cce5041dfaf465388b295df2ffe80e7",
"Id": "5cce5041-dfaf-4653-88b2-95df2ffe80e7",
"IdExternal": null
},
{
"SummaryTask_Id": "5cce5041-dfaf-4653-88b2-95df2ffe80e7",
"Project_Id": "180d9cb5-068a-423c-939d-e090d6f39cb6",
"IsSummaryTask": false,
"DurationSeconds": 0,
"WorkSeconds": 0,
"StartDateTimeUTC": "2018-07-10T15:00:00Z",
"EndDateTimeUTC": "2018-07-10T15:00:00Z",
"WorkPercentComplete": 0.00,
"WorkPercentCompleteType_Id": "6b1ed2b6-881a-4ea8-affc-8ca182a594e3",
"CustomFieldValue_Id": "a06587ac-2e82-411e-8bda-baed5e83dd59",
"IsActive": true,
"Name": "Child of Summary #1",
"UrlFull": "http://dev33.sandbox.projectinsight.net/ProjectInsight.WebApp/task/ce24a21ab03944e3ab0926172e64ccf3",
"Id": "ce24a21a-b039-44e3-ab09-26172e64ccf3",
"IdExternal": null
},
{
"SummaryTask_Id": "5cce5041-dfaf-4653-88b2-95df2ffe80e7",
"Project_Id": "180d9cb5-068a-423c-939d-e090d6f39cb6",
"IsSummaryTask": true,
"DurationSeconds": 0,
"WorkSeconds": 0,
"StartDateTimeUTC": "2018-07-10T15:00:00Z",
"EndDateTimeUTC": "2018-07-10T15:00:00Z",
"WorkPercentComplete": 0.00,
"WorkPercentCompleteType_Id": "6b1ed2b6-881a-4ea8-affc-8ca182a594e3",
"CustomFieldValue_Id": "dd8469a5-65d4-4aaf-a9c2-1d978e4805d1",
"IsActive": true,
"Name": "Summary Child Task #2",
"UrlFull": "http://dev33.sandbox.projectinsight.net/ProjectInsight.WebApp/task/1ece43a20b824307b974bc33dfb6c78a",
"Id": "1ece43a2-0b82-4307-b974-bc33dfb6c78a",
"IdExternal": null
},
{
"SummaryTask_Id": null,
"Project_Id": "180d9cb5-068a-423c-939d-e090d6f39cb6",
"IsSummaryTask": true,
"DurationSeconds": 0,
"WorkSeconds": 0,
"StartDateTimeUTC": "2018-07-10T15:00:00Z",
"EndDateTimeUTC": "2018-07-10T15:00:00Z",
"WorkPercentComplete": 0.00,
"WorkPercentCompleteType_Id": "6b1ed2b6-881a-4ea8-affc-8ca182a594e3",
"CustomFieldValue_Id": "4fb96243-aa51-4fc0-8324-99cbe6c876a6",
"IsActive": true,
"Name": "Summary Task #2",
"UrlFull": "http://dev33.sandbox.projectinsight.net/ProjectInsight.WebApp/task/8f2b98c980e94635baa6edb1f7c05cfb",
"Id": "8f2b98c9-80e9-4635-baa6-edb1f7c05cfb",
"IdExternal": null
},
{
"SummaryTask_Id": "8f2b98c9-80e9-4635-baa6-edb1f7c05cfb",
"Project_Id": "180d9cb5-068a-423c-939d-e090d6f39cb6",
"IsSummaryTask": false,
"DurationSeconds": 0,
"WorkSeconds": 0,
"StartDateTimeUTC": "2018-07-10T15:00:00Z",
"EndDateTimeUTC": "2018-07-10T15:00:00Z",
"WorkPercentComplete": 0.00,
"WorkPercentCompleteType_Id": "6b1ed2b6-881a-4ea8-affc-8ca182a594e3",
"CustomFieldValue_Id": "2a1be80b-2022-4293-974b-58a9c9b188db",
"IsActive": true,
"Name": "Child Task of Summary #2",
"UrlFull": "http://dev33.sandbox.projectinsight.net/ProjectInsight.WebApp/task/1d0143f26a02421ebd964c6744d6e55f",
"Id": "1d0143f2-6a02-421e-bd96-4c6744d6e55f",
"IdExternal": null
}
]0 -
Robert,
Yes, I can get them that way. In fact, I am. I was originally attempting to get them via Project.Get. That is where only the Summary tasks show up. So I have added in an extra step / call to the API to return that piece of the project data using Tasks.GetByProject. I had forgotten that I had added the comment letting you know that I could get the tasks that way.
So here is the C# for getting all of the tasks for a project with the attendant Resource information;
modProp.ModelPropertyLists.Clear();
modProp.AddModelPropertyList("Task", "IsMilestone,IsSummaryTask,DurationSeconds,WorkSeconds,StartDateTimeUTC,EndDateTimeUTC,WorkPercentComplete,Name,ResourceType,TaskResources");
modProp.AddModelPropertyList("ResourceType", "Name");
modProp.AddModelPropertyList("TaskResource", "IsTaskOwner,PercentAllocation,WorkPercentComplete,User");
modProp.AddModelPropertyList("User", "FirstName, LastName");
List<ProjectInsight.Models.Tasks.Task> theseTasks = client.Task.GetByProject(projId, modelProperties: modProp); // get the Task Resource data
I then iterate "theseTasks" skipping the "IsSummaryTask == true" items and getting the Task and TaskResource data I need. Calculating whether the task is Open, Closed and Overdue and applying some other supporting info.
Thank you and appreciated,
G
0
Please sign in to leave a comment.
Comments
6 comments