AX- D365FO – Get the root project or all the ancestors of a given project in ProjTable follow these instructions.
To get the root project of a given project
ProjTable::getRootProjId(ProjId)


Returns the root project
To get all the ancestors of a given project
ProjTable::ancestors(projId);


ProjTable::ancestors(projId) returns a container of all ancestor of a project