Tuesday, January 5, 2016

Calling/Opening AX form through X++

Sample piece of code to open AX form through X++

static void OpenForm_ThroughCode(Args _args)
{
    Args                            args;
    Object                          formRun;

    // open form
    args = new Args();
    args.name(formstr(FormName));
    formRun = classfactory.formRunClass(args);
    formRun.init();
    formRun.run();
    formRun.wait();
}

If you want to pass a record to open a form

args = new Args();
args.record(ProjTable::find('PR00001'));
args.name(formstr(FormName));
formRun = classfactory.formRunClass(args);
formRun.init();
formRun.run();

formRun.wait();

How to retrieve these args on caller form's init()

public void init()
{
    ProjTable   projTableLocal;   
    super();   
    projTableLocal = element.args().record();   
}

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Hello,

    I had used the above code to calling other form from grid. I have grid and open the other form by double clicking on the any grid record. In grid, there are columns ( ServiceID,CustID,CustomerName etc...). My problem is that When I double click on grid, it will open ServiceOrder form(SO NO : So-10001) then again double click on the grid,again open the serviceorder form(SO NO : So-10002). Means two Serviceorder forms will be opened with different SO number like (So-10001 and So-10002) but after that in both ServiceOrder forms, it display the same ServiceId and same details. I don't know why it happend.Can you please guide me? Thanks in advance.

    ReplyDelete

I will appreciate your comments !

How to enable new Microsoft teams - Public Preview!

New Microsoft Teams is just AWESOME, quick but useful post below shows how you have this preview feature to make your life EASY!  Open Micr...