Dynamics Ax RunBase overriding dialog with a Form


Hi,

Some time ago I’ve found out that you can implement a form into a RunBase dialog, this has the advantage that you can easily use a grid control, etc… or use modified field methods without using controlMethodOverload() method. You can do this by overriding the dialog method and adding the following code.

DialogRunbase  dialogRunbase = Dialog::newFormnameRunbase(formstr(BLOGRunBaseDialogExample), this);
;
return super(dialogRunbase);
Code language: JavaScript (javascript)

You can still add fields the normal way by using the addFieldValue() method, these fields will appear next to the embedded form.

This form must have a Tab control and some hardcoded groups, also on the design the property FrameType must be set to None. The groups I’ve created are DialogStartGrp and RightButtonGrp, these are used for positioning fields and query values from code. More groups may be necessary when extending from RunBaseBatch, RunBaseReport, …  The tab control is used for adding a batch tab when extending from RunBaseBatch.

Form example

In the dialogPostRun() method you can get the formRun of the dialog and make calls to the form, for example setting query ranges.

public void dialogPostRun(DialogRunbase dialog)
{
    Object  formRun;
    ;

    if(FormHasMethod(dialog.formRun(),"setQueryRanges"))
    {
        formRun = dialog.formRun();
        formRun.setQueryRanges();
    }

    super(dialog);
}
Code language: JavaScript (javascript)

A way to pass data or do callbacks is to get the calling class in the form init.

public void init()
{
    super();

    if( element.args()                                  &&
        element.args().caller()                         &&
        element.args().caller().RunBase()               &&
        ClassIdGet(element.args().caller().RunBase())   == ClassNum(BLOGRunBaseDialogExample))
    {
        // Do something
    }
}
Code language: JavaScript (javascript)
, ,

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.