Handling Priorities

A task’s priority helps Microsoft Project with automatic resource leveling (a process of fixing conflicts when a resource is over-allocated). In Microsoft Project, it is possible to assign priority values between 0 and 1000 (where 0 is the lowest priority). By default, tasks are assigned the value 500.

Working with Priorities

The priorities associated with a class are handled through the PRIORITY property exposed by the Tsk class.

Priorities in Microsoft Project

To check a task’s priority in Microsoft Project one can double-click a task in the Task Entry form:

Task priority in Microsoft Project

checking task priorities in Microsoft Project

Getting a Task’s Priority

The following examples show how to get a task’s priority and write it to a console window using Aspose.Tasks.

 1// For complete examples and data files, please go to https://github.com/aspose-tasks/Aspose.Tasks-for-Java
 2// The path to the documents directory.
 3String dataDir = Utils.getDataDir(HandlePriorities.class);
 4
 5Project project = new Project(dataDir + "input.mpp");
 6
 7// Create a ChildTasksCollector instance
 8ChildTasksCollector collector = new ChildTasksCollector();
 9
10// Collect all the tasks from RootTask using TaskUtils
11TaskUtils.apply(project.getRootTask(), collector, 0);
12
13// Handling Priorities:
14// Parse through all the collected tasks
15for (Task tsk : collector.getTasks()) {
16    System.out.println(tsk.get(Tsk.PRIORITY).toString());
17}
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.