none
How can you get the sub-projects of an IMS through the Project Server 2016 REST API? RRS feed

  • Question

  • I know that in the ProjectServer REST API, there is a property on Task objects called IsSubProject.  So I can get all the summary tasks that represent sub projects within a master schedule by this query:

    /_api/ProjectServer/Projects('project-id-here')/Tasks?$filter=IsSubProject eq true

    But, then I can't figure out how to get the Project objects for those sub projects.  I can't do a query of all projects and filter by name, because the summary task name can be different than the actual file name/project name of the Project.  And the Task Id does not match the Project Id.

    I can get the corresponding Task objects from the ProjectData service, but there doesn't seem to be any additional information linking it to the actual sub-project Project. (The ProjectData tasks don't even have "IsSubProject".)

    How can I get to the sub-project's Projects?


    • Edited by DylanCristy Monday, November 20, 2017 10:46 PM
    Monday, November 20, 2017 8:26 PM

Answers

  • Hello,

    What about using the ProjectData service, query to get all of your master projects (ProjectType eq '6') then use those ProjectIds to get the list of sub projects using the ParentProjectId property then once you have those projects you can get the tasks?

    Paul


    Paul Mather | Twitter | http://pwmather.wordpress.com | CPS | MVP | Downloads

    • Marked as answer by DylanCristy Tuesday, November 21, 2017 5:11 PM
    Tuesday, November 21, 2017 11:44 AM
    Moderator

All replies

  • Hello,

    What about using the ProjectData service, query to get all of your master projects (ProjectType eq '6') then use those ProjectIds to get the list of sub projects using the ParentProjectId property then once you have those projects you can get the tasks?

    Paul


    Paul Mather | Twitter | http://pwmather.wordpress.com | CPS | MVP | Downloads

    • Marked as answer by DylanCristy Tuesday, November 21, 2017 5:11 PM
    Tuesday, November 21, 2017 11:44 AM
    Moderator
  • Aha, yes!  Thanks, this is exactly the kind of info I was looking for!  I don't know why I had glossed over the ParentProjectId property while looking for solutions.

    Yes it looks like this will work, but another (related) question - does the ParentProjectId relationship hold true for more deeply nested sub projects?  I.E.

    IMS, ProjectType: 6, ProjectId: 1111, ParentProjectId: null

        SubProject1, ProjectType: 5, ProjectId: 2222, ParentProjectId: 1111

            SubProject2, ProjectType: 5, ProjectId: 3333, ParentProjectId: 2222

                SubProject3, ProjectType: 5, ProjectId: 4444, ParentProjectId: 3333

    My gut feeling is that it should, that would seem logical, but you never know, maybe the ParentProjectId always points back to the master project (the parent with ProjectType: 6)?

    Tuesday, November 21, 2017 3:22 PM
  • That is correct, in that example, SubProject1 and 2 would be master projects with a ProjectType 6. Just tested this quickly with 3 projects:

    Paul


    Paul Mather | Twitter | http://pwmather.wordpress.com | CPS | MVP | Downloads


    Tuesday, November 21, 2017 4:26 PM
    Moderator
  • Ok, thanks, good to know.  Thanks for testing it!
    Tuesday, November 21, 2017 5:11 PM