We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to find task by uid of task?

I created Project by load a mpp file.

I want to find a task by uid of task, how to do? What interface that I can invoke?

Hi,


Thank you for contacting Aspose support team.

You may please use getByUid() function to retrieve a task from the project. Following is the sample code which demonstrates this function.

Project proj = <span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:navy”>new
Project(<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:green”>“Project1.mpp”
);

Task task1 = proj.getRootTask().getChildren().getByUid(
<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:blue”>1);

System.
<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:#660E7A”>out
.println(<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:green”>"Task Name = "
+ task1.get(Tsk.<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:#660E7A”>NAME
));

Hi,

Thank you for anwer my question, but I still have a question, If I have 3 level, not 1 level, how to get the task by uid? I describe it as below, and I want to get the task6, it means I need do proj.getRootTask().getChildren().getByUid(3).getChildren().getByUid(5).getChildren().getByUid(6)?
Any simple method that I can use?


roottask
task1 uid=1
task2 uid=2
task3 uid=3
task4 uid=4
task5 uid=5
task6 uid=6
task7 uid=7
task8 uid=8
task9 uid=9

Hi,

The task UID is unique irrespective of its level in the project and you can use it for getting the child task of root as shown in the following code sample.

Sample Code:

Project project = new Project(“713917\Project1.mpp”);

Task task = project.getRootTask().getChildren().getByUid(6);

System.out.println(task.get(Tsk.Name));