Identify Cross Project Tasks
In large projects, tasks are sometimes linked across multiple project files. For example, a task in one project may depend on a task from another project. These are known as cross project tasks (or external tasks).
When this happens, the same task may have different IDs in the original project and the external project where it is referenced.
Aspose.Tasks for .NET provides APIs to programmatically detect and analyze such tasks, ensuring that cross project dependencies can be handled correctly.
How to Identify Cross Project Tasks
When a task is linked from one project file to another:
- The Id property of the Task class returns the identifier of the task in the external project (where the task is referenced).
- The ExternalId property returns the identifier of the task in the original project (where the task was first created).
This distinction makes it possible to track the same task across multiple projects and avoid confusion in reporting or scheduling.
The following image demonstrates how external tasks appear in Microsoft Project:
Example: Identifying External Task IDs
The code below shows how to read both the original and external IDs of a cross project task using Aspose.Tasks for .NET:
1Project project = new Project("New Project.mpp");
2Task task = project.RootTask.Children.GetByUid(1);
3
4// Show ID of the task in the external project
5Console.WriteLine(task.Get(Tsk.Id).ToString());
6
7// Show ID of the task in the original project
8Console.WriteLine(task.Get(Tsk.ExternalId).ToString());
Conclusion
Cross project task links are a powerful feature in Microsoft Project, but they can introduce complexity when analyzing schedules.
By using the Id
and ExternalId
properties of the Task
class in Aspose.Tasks for .NET, developers can reliably distinguish between original and external tasks, enabling accurate reporting and seamless management of multi-project environments.