Dynamics Search Engine

Thursday, June 5, 2008

How to open Dynamics Ax form through X++ code

This article shows how to open forms in Dynamics Ax through X++ code.
Note: Use at your own risk.
You should be familiar with X++ basic programming.

I applied it on Dynamics Ax 3.0

1) Open your Ax application then AOT.
2) Go to Jobs node and create a new job.
3) Add the following codes in your job to open a form by menuitem name.

MenuFunction menuFunction;
;
menuFunction = new MenuFunction(MenuItemDisplayStr(CustTable), MenuItemType::Display);
menuFunction.run();

Your job will look like:

static void Job1(Args _args)

{
MenuFunction menuFunction;
;
menuFunction = new MenuFunction(MenuItemDisplayStr(CustTable), MenuItemType::Display);
menuFunction.run();
}



You can open your form by form name also.
1) Create a new job.
2) Copy the below code and paste to your job.

static void Job2(Args _args)
{
Args args;
FormRun formRun;
;
args = new Args();
args.name(formstr(CustTable));
formRun = new FormRun(args);
formRun.run();
formRun.wait();
}