I am writing a utility for our local development team to export project information (stories, resources, etc) from our agile management system to Microsoft Project 2010 and using MPXJ and C# to accomplish this. It was very straightforward using the examples to put together code to generate either an MPX or MSPDI output file that successfully imports into MS Project. However... the format we desire is multi-level, like this:
Project -> TaskA -> TaskASubtask1
-> TaskASubtask2
-> TaskB -> TaskBSubtask1
-> TaskBSubtask2 -> TaskBSubSubtask1
and when I naively add child tasks in random order (the input stream is not sorted nicely), the WBS level values for the tasks look correct but the task after import is located under the immediately previous task in the generated file.
I had read that properly ordering the file was a bug fixed back in 4.3.0 (as I recall) so I did not think I needed to add tasks in the "correct" order. I found that if I used the MpxCreate.cs example and moved the task creation "out of order" I saw the same behavior where the task hierarchy was not presented as you might expect in MS Project.
This simple code snippet results in an "out of order presentation" in MS Project (Second Sub Task is nested under Next Task):
Task task1 = file.AddTask();
task1.Name = "Summary Task";
Task task2 = task1.AddTask();
task2.Name = "First Sub Task";
Task task4 = file.AddTask();
task4.Name = "Next Task";
Task task3 = task1.AddTask();
task3.Name = "Second Sub Task";
Should this work? Or should I reorder my task creation so that each hierarchy is completely filled in all at once?
I am going to continue to play with it but I welcome any insights.
Thanks, Owen
I had the exact same problem. The exported XML-File is imported to MS Project 2010 correctly if I call the following function before exporting:
(The answer from Jon Ilnes was a good hint but not 100% correct, because the
getTasks()
was missing in the middle.)