Archive

Posts Tagged ‘compiler’

Creating a custom compiler output type and displaying in the compiler output in Dynamics Ax 2009

May 5, 2011 5 comments

This article will guide in creating a custom compiler output Type like “To Do” , “Error” and “Best Practices” in Dynamics Ax 2009.

0. First change your compiler to “Message window” until you complete this. Retaining it as “Form” might result in runtime errors which cannot be resolved. This is because it will stop your compiler from executing and consequently any further progress.

1. Add a element to the enum “SysCompilerOutput”. Let’s call it “Custom”

2. Add a new datasource to the Form “SysCompilerOutput” for the table “TmpCompilerOutput”. Name it “Custom”. Also create a tab, grid and drag fields to it.

3. Now override the “init” method of the datasource and write the following code.

public void init()
{
    QueryBuildRange range;
    ;

    super();
    range = this.query().dataSourceNo(1).addRange(fieldnum(TmpCompilerOutput, SysCompilerOutputTab));
    range.value(queryValue(SysCompilerOutputTab::Custom));
    range.status(RangeStatus::Hidden);
}

4. Go to class “\Classes\SysCompilerOutput” and create a global variable “Custom_Ds” and create a parm method for this datasource like “\Classes\SysCompilerOutput\parmBestPractices_ds

5. Go to “\Classes\SysCompilerOutput\updateDataSources ” and add the following lines


        this.updateCursor(custom_ds, tmpCompilerOutput);
        custom_ds.research();

6. Now change your compiler output to “Form”

7. Run the following Job to test it.

static void JobTestCompiler(Args _args)
{
    SysCompileroutput     output;
    ;

    output = infolog.compilerOutput();

    output.compilerOutputMessage('Custom Message 1', 66, 1, 2, 3, 'Just a try', 'Method name', SysCompilerOutputTab::Custom);
    output.compilerOutputMessage('Custom Message 2', 85, 1, 2, 3, 'Second Try', 'Property name', SysCompilerOutputTab::Custom);
}

8. Now you can make the above call from any place in the application to add contents to the compiler output tab.

**Just a note, This is only to start with it. You may want to setup your own custom error messages, error codes, images. You have to explore forward from here to accomplish those.**