Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Server

Microsoft Dynamics AX 2009 : Processing Business Tasks - Creating company-specific document layout

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
1/30/2012 5:31:37 PM
In most of the multi-company projects on which I have worked on, I was asked to created separate layouts for documents like Purchase order or Sales invoice for each Dynamics AX company. One of the approaches was to create several Dynamics AX report designs and switch them by calling the report member method design() depending on the company the user is. But this method proved to be too complicated, especially when the report logic is different for each company and it is much more difficult to control changes if the same report is used in more than two companies.

Another more convenient approach, which I used for a number of implementations, was to use a separate report for each company and switch them depending on in which company it is being printed.

In this recipe, we will demonstrate the latter technique to print different reports per company. As an example we will use a Purchase Order document.

How to do it...

  1. 1. In AOT make a duplicate of the PurchPurchaseOrder report. Name it PurchPurchaseOrder2 and change its purchaseOrderTxt() method found in the PurchaseOrder section to:

    display str purchaseOrderTxt()

    {
    return "PurchPurchaseOrder2";
    }
  2. 2. In AOT, create a new class called PurchPurchaseOrder with the following code (replace CEU with one of your company codes):

    class PurchPurchaseOrder

    {
    }
    public static void main(Args _args)

    {
    ReportRun reportRun;
    ReportName reportName;
    ;
    switch (curext())
    {
    case 'CEU':
    reportName = reportstr(PurchPurchaseOrder2);
    break;
    default:
    reportName = reportstr(PurchPurchaseOrder);
    break;
    company specific document layoutcompany specific document layoutcreating, steps}
    _args.name(reportName);
    reportRun = new ReportRun(_args);
    reportRun.init();
    reportRun.run();
    }


  3. 3. Modify the properties of the PurchPurchaseOrder, PurchPurchaseOrderCopy, and PurchPurchaseOrderOriginal Output menu items as following:

    Property Value
    ObjectType Class
    Object PurchPurchaseOrder

  1. 4. To test, open Accounts payable | Purchase Order Details, select any open purchase order and post it using the Post | Purchase order button. If the current company matches the company defined earlier, i.e. CEU, the report title should look like the following:

How it works...

In this recipe, first we make a copy of the existing purchase order report and change its title. This is done only to make sure we can distinguish which report is printed. Normally, PurchPurchaseOrder2 should be a valid report for one of the companies.

PurchPurchaseOrder is the main place where report switching is done. It is like a thin layer between the report caller and the report itself. All the code is placed in its main(). Here we are using a switch statement to define rules determining which report is printed. For demonstration purposes we print the standard purchase order report in all cases except when the current company is CEU. In this case, we print a newly created PurchPurchaseOrder2. In real environments this code has to be modified, so that it reads the report name from some parameters table, for example VendFormletterParameters, which is a data source of Accounts payable | Setup | Forms | Form setup. The rest of the code runs the report from code.

The final bit is to modify all menu items that are used to run the report. For a purchase order there are three menu items— PurchPurchaseOrder, PurchPurchaseOrderCopy, and PurchPurchaseOrderOriginal— that allow opening the purchase order document report. We need to make sure that our class is called here. Same principle could be applied for other purchase and sales business documents.

Other -----------------
- Microsoft Dynamics AX 2009 : Processing Business Tasks - Posting sales orders
- Active Directory Domain Services 2008 : Add a Computer to a Group
- Active Directory Domain Services 2008 : Move a Computer Object
- Windows Server 2008 Server Core : Starting and Configuring the Registry Editor (part 2)
- Windows Server 2008 Server Core : Starting and Configuring the Registry Editor (part 1)
- Microsoft BizTalk 2010 : Consuming ASDK-based Adapters - Installation
- Microsoft BizTalk 2010 : Understanding the ASDK-based adapter
- Microsoft Dynamics CRM 4.0 Accelerators : eService Accelerator (part 4)
- Microsoft Dynamics CRM 4.0 Accelerators : eService Accelerator (part 3) - Modify the New Workflows & eService Configuration
- Microsoft Dynamics CRM 4.0 Accelerators : eService Accelerator (part 2)
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server