Logo
HOW TO
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
 
 
Windows Server

Microsoft Dynamics AX 2009 : Integration with Microsoft Office - Exporting data to Microsoft Project

12/2/2012 11:27:57 AM
Probably, everybody knows that new Dynamics AX 2009 supports two-way synchronization with Microsoft Project Server. Sounds good, but in reality it takes a lot of effort to install and configure all the required components. This feature is also not available for older versions of Dynamics AX. But, what if one wants to simply display Dynamics AX project data as nice chart without installing and configuring additional features? Of course, you could use the integrated Gantt chart ActiveX, but this again cannot be used that smoothly in practice, especially when it is not possible to save it as a file and share it with other people.

Another approach, which I successfully implemented in one of my projects, could be to use Microsoft Project for displaying Dynamics AX project data. In this case, the data is displayed in a well known format and what is very important is that it can be stored as a Microsoft Project file for further usage.

In this recipe, we will use Microsoft Project to display Dynamics AX hours forecast data in the Project module. Here we are going to use COM objects to access Microsoft Project in a similar way in which we accessed Excel and Word.

Getting ready

We again need to set up some demonstration data. Open the Project Details form from the Project module. Create a new or select an existing open project. In my case, I selected project No. 10001. Click on the Forecast | Hour button to open the Hours forecast form, and create several forecast lines. I created the following records:

Field Value
Forecast model P-2008
Category Service
Transaction text Inspection 1
Hours 20
Work center 00201

Field Value
Forecast model P-2008
Category Service
Transaction text Inspection 2
Hours 12
Work center 00201

The data entered in the Overview tab page should look as shown in the following screenshot:

To update scheduling, click Schedule and click OK to accept the default parameters.

Now, the information on the Scheduling tab page should look like the following:

How to do it...

  1. 1. In AOT, create a new class called CreateProjectFile with the following code:

    class CreateProjectFile
    
    {
    }
    public client static void main(Args _args)
    
    {
    ProjTable projTable;
    ProjForecastEmpl forecastEmpl;
    ProjForecastEmpl parmForecastEmpl;
    COM msproject;
    COM projects;
    COM project;
    COM tasks;
    COM task;
    int n;
    #define.MSProject('MSProject.Application')
    ;
    if (!_args ||
    _args.dataset() != tablenum(projForecastEmpl))
    {
    throw error(Error::missingRecord(funcname()));
    }
    parmForecastEmpl = _args.record();
    projTable = ProjTable::find(parmForecastEmpl.ProjId);
    try
    {
    msproject = new COM(#MSProject);
    }
    catch (Exception::Internal)
    {
    if (msproject == null)
    {
    throw error(
    "Microsoft Project is not installed.");
    }
    }
    projects = msproject.Projects();
    project = projects.Add();
    tasks = project.Tasks();
    task = tasks.Add();
    task.Name(ProjTable.Name);
    task.OutlineLevel(1);
    while select forecastEmpl
    where forecastEmpl.ProjId == projTable.ProjId
    && forecastEmpl.ModelId == parmForecastEmpl.ModelId
    {
    task = tasks.Add();
    task.OutlineLevel(2);
    task.Name(forecastEmpl.Txt);
    task.Start(forecastEmpl.SchedFromDate);
    task.Duration(forecastEmpl.SchedTimeHours*60);
    if (n)
    data export, to Microsoft Projectdata export, to Microsoft Projectsteps{
    task.LinkPredecessors(tasks.UniqueID(n));
    }
    n = task.UniqueID();
    }
    msproject.visible(true);
    }
    
    
    					  
  2. 2. In AOT, create a new Action menu item with the following properties:

    Property Value
    Name CreateProjectFile
    ObjectType Class
    Object CreateProjectFile
    Label Export to Microsoft Project

  1. 3. Add the created menu item to the bottom of the ProjForecastEmpl form's ButtonGroup group. Set its properties to:

    Property Value
    Name CreateProjectFile
    MenuItemType Action
    MenuItemName CreateProjectFile
    DataSource ProjForecastEmpl

  1. 4. In AOT, the form should look like the following:

  1. 5. To test the export file, open Project | Project Details, select the project mentioned earlier, go to Forecast | Hour, and click the Export to Microsoft Project button to view the forecasted hours as a Microsoft Project plan:

How it works...

For the purpose of this recipe, we created a new class and placed all code in its main() method. The code starts with checking the input record, initializing the projTable record, and starting the Microsoft Project application.

Using the Microsoft Project model hierarchy, we first get a reference to the project collection object projects. Then, we create a new project by calling Add(). Each project contains a task collection, where we could add new tasks by calling its Add(). We do exactly that for the first level in the project plan, i.e. we create a task whose name is a project name and set its level to 1.

Next, we loop through all Dynamics AX project hour forecast records and start inserting tasks into the Microsoft Project chart into the next level, i.e. 2. Here, we call Add() on the task collection again to create a new task object called task. We set its properties like name, start date, and duration. We also define every task to be dependent on the previous one by calling LinkPredecessors() with the number of the previous task as an argument.

Once the code is executed, we make Microsoft Project along with the diagram visible to the user.

Finally, we create a new Action menu item pointing to our class and add this item to the Hours forecast form to make sure the user is able to run it for a selected Dynamics AX project.

Depending on the requirements, this technique could be used to control other aspects like resources, custom properties, and other objects provided by the Microsoft Project COM model.

Other -----------------
- Microsoft Content Management Server : The ASP.NET Stager Application (part 3) - Staging Attachments
- Microsoft Content Management Server : The ASP.NET Stager Application (part 2) - Staging Channels and Postings
- Microsoft Content Management Server : The ASP.NET Stager Application (part 1) - The DotNetSiteStager Project, Recording Messages to a Log File
- Microsoft Content Management Server : Staging Static Pages - Site Stager in Brief
- BizTalk 2010 : WCF LOB SQL Adapter - Consuming ASDK SQL Adapter in Visual Studio (part 2)
- BizTalk 2010 : WCF LOB SQL Adapter - Consuming ASDK SQL Adapter in Visual Studio (part 1)
- Windows Server 2008 Server Core : Renaming a File with the Ren and Rename Commands, Sorting File Content with the Sort Utility
- Windows Server 2008 Server Core : Moving Files and Renaming Files and Directories with the Move Command, Recovering Lost Files with the Recover Utility
- Windows Server 2008 : Moving Accounts with dsmove, Removing Objects with dsrm, Retrieving Information about Objects with dsquery
- Windows Server 2008 : Modifying Accounts with dsmod
 
 
REVIEW
- First look: Apple Watch

- 10 Amazing Tools You Should Be Using with Dropbox

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
 
VIDEO TUTORIAL
- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 1)

- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 2)

- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 3)
 
Popular tags
Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Indesign Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe After Effects Adobe Photoshop Adobe Fireworks Adobe Flash Catalyst Corel Painter X CorelDRAW X5 CorelDraw 10 QuarkXPress 8 windows Phone 7 windows Phone 8 BlackBerry Android Ipad Iphone iOS
Popular keywords
HOW TO Swimlane in Visio Visio sort key Pen and Touch Creating groups in Windows Server Raid in Windows Server Exchange 2010 maintenance Exchange server mail enabled groups Debugging Tools Collaborating
Top 10
- Microsoft Excel : How to Use the VLookUp Function
- Fix and Tweak Graphics and Video (part 3) : How to Fix : My Screen Is Sluggish - Adjust Hardware Acceleration
- Fix and Tweak Graphics and Video (part 2) : How to Fix : Text on My Screen Is Too Small
- Fix and Tweak Graphics and Video (part 1) : How to Fix : Adjust the Resolution
- Windows Phone 8 Apps : Camera (part 4) - Adjusting Video Settings, Using the Video Light
- Windows Phone 8 Apps : Camera (part 3) - Using the Front Camera, Activating Video Mode
- Windows Phone 8 Apps : Camera (part 2) - Controlling the Camera’s Flash, Changing the Camera’s Behavior with Lenses
- Windows Phone 8 Apps : Camera (part 1) - Adjusting Photo Settings
- MDT's Client Wizard : Package Properties
- MDT's Client Wizard : Driver Properties
 
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
2015 Camaro