Showing posts with label open form in ax 2012. Show all posts
Showing posts with label open form in ax 2012. Show all posts

Thursday, 24 December 2015

Opening AX Form through code with ranges

//Write following code in your job
//————————————
void ABC_OpenFormCode()

{
   CustTable       _CustTable;
   str             menuItemStr;
   MenuFunction    menuFunction;
   Args            args = new Args();

   ;
   Select _CustTable where _CustTable.AccountNum == ’1111′;
   args.record(_CustTable);

   menuItemStr = menuitemdisplaystr(ABC_TestForm);
   menuFunction = new MenuFunction(menuItemStr, MenuItemType::Display);
   menuFunction.run(args);

}
//Write following code in your form-datasource-init() method (Here the example for CustTable)
//———————————————————-

public void init()
{
   CustTable  _CustTable;
   ;
   super();

   _CustTable = element.args().record();

   this.query().dataSourceTable(tablenum(CustTable)).addRange(fieldnum(CustTable,AccountNum)).value(_CustTable.AccountNum);

}

Opening AX Form through code with ranges

//Write following code in your job
//————————————
void ABC_OpenFormCode()

{
   CustTable       _CustTable;
   str             menuItemStr;
   MenuFunction    menuFunction;
   Args            args = new Args();

   ;
   Select _CustTable where _CustTable.AccountNum == ’1111′;
   args.record(_CustTable);

   menuItemStr = menuitemdisplaystr(ABC_TestForm);
   menuFunction = new MenuFunction(menuItemStr, MenuItemType::Display);
   menuFunction.run(args);

}
//Write following code in your form-datasource-init() method (Here the example for CustTable)
//———————————————————-

public void init()
{
   CustTable  _CustTable;
   ;
   super();

   _CustTable = element.args().record();

   this.query().dataSourceTable(tablenum(CustTable)).addRange(fieldnum(CustTable,AccountNum)).value(_CustTable.AccountNum);

}