1

I am trying to extract the basic task and resource information from an MS Project 2010 .mpp file using MPXJ - Java. I have no problem opening up the file and dumping all the tasks, but the problem comes in when trying to access the resources assigned to the task. I am calling Task.GetResourceNames(), but it is returning null everytime. I have also tried calling Task.GetResourceAssignments(), but this also returns null everytime.

I created a very, very simple project with one summary task, three subtasks, linked together, and had a different resource assigned to each one of these.

When I run my program, I see all the tasks, but the call to GetResourceNames() still returns null.

Am I going at this through the wrong interface?

1 Answers1

0

You can see in the javadoc that for mpp files, GetResourceNames() return always null. To get the resources names from a specific tasks, this is how I did :

            List<ResourceAssignment> Resources = task.getResourceAssignments();
// getResourceAssignments() return a list of ResourceAssignment of a specific task.
            Iterator i = Resources.iterator();

            while (i.hasNext()) {
                ResourceAssignment ra = (ResourceAssignment) i.next();
                Resource r = ra.getResource();
// we get the resource from the resource assignment
                System.out.println("\t Assigned Resources : " + r.getName());
// print the name of the Resource. If you want to do the same than GetResourceNames, just add each name in a String and you will have the same results at the end.
            } 

Hope this helps.

Bdloul
  • 882
  • 10
  • 27