I want to extract the planned work over the time from MS Project using MPXJ.
Does anyone know how to get these figures via API?
I cannot find any appropriate method for doing this.
(Concrete scenario: I want to draw a chart with the planned work on the y-axis and the date on the x-axis)
your starting point is the following methods on the assignment object:
As their names suggest, these will get you either the planned work or the complete work, expressed as work carried out over periods of time.
The “gotcha” here is that this data is represented in a compact format (reflecting how it’s stored by MS Project internally), and this does not lend itself well to showing a period-by-period breakdown of work.
To get what you want, there are two utility classes which will help you to convert this compact representation into a list of work values. For example, you can give them a start date a period type (day, week, month and so on) and a number of periods, and ask for the work to be broken down over these periods.
First step is to create an instance of the TimescaleUtility class, and get it to generate a range of dates for you. You give it the start date, the timescale units you require, and the numnber of periods you want.
The dateList variable now contains the list of date ranges you are going to split the work over. This split is carried out using the TimephasedUtility class:
That’s it, your durationList now contains one entry for each entry in the datList showing the amount of work for that period.
Hope that makes sense!
Jon