Identify Cross Project Tasks

How to Identify Cross Project Tasks

If you have linked a task from one project to a task from the other project, the IDs and UIDs of the task is different in the original and external projects as you can see in the following image.

Internal and external IDs in Microsoft Project

showing up cross links in Microsoft Project

The ExternalId property exposed by the Task class is used to find an external task’s original ID. The Id property returns the ID of the external task in the external project whereas the ExternalId property returns the ID of the external task in the original project.

The code example given below finds the original and external ID of a task.

 1// Create project instance and access task
 2System::String dataDir = RunExamples::GetDataDir(System::Reflection::MethodBase::GetCurrentMethod(ASPOSE_CURRENT_FUNCTION)->get_DeclaringType().get_FullName());
 3System::SharedPtr<Project> project1 = System::MakeObject<Project>(dataDir + u"External.mpp");
 4System::SharedPtr<Task> externalTask = project1->get_RootTask()->get_Children()->GetByUid(1);
 5    
 6// Show ID of the task in the external project
 7System::Console::WriteLine(System::Convert::ToString(externalTask->Get<int32_t>(Tsk::Id())));
 8    
 9// Show ID of the task in the original project
10System::Console::WriteLine(System::Convert::ToString(externalTask->Get<int32_t>(Tsk::ExternalId())));
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.