Tuesday, 15 October 2013

Passing the records between the forms Dynamic AX

1.       Create a formA with datasource as CustTable and grid in the design with the same datasource and one button.
2.       Overrode the clicked method of button in FormA
void Clicked()
{
Args    _args;
FormRun _formRun;
AccountNum      _accountNum;
;
_accountNum = CustTable.AccountNum;  // Selected AccountNum in the Grid is assigned to the variable which is pass to the next form
_args = new Args(); // creating a object for args class
_args.name(formstr(CustomerSelectionRecordsA));  // Form Menuitem
_args.caller(this);  // Form Caller(Current Form is mentioned as this)
_args.parm(_accountNum); // Employee Number is passed to next form[but parm() is not a best practise]
_args.record(CustTable); // Table name is passed
_formRun = ClassFactory.formRunClass(_args); //new FormRun(_args);   // Creating object for FormRun
_formRun.init();   // Form Initialization for Load
_formRun.run();  // Form Run for process
_formRun.wait(); // Form Wait for Display
}
3.       


4.       Create another formB with same as formA design.
5.       Override the init() of the formB
public void init()
{
parmid      _parmId;
CustTable   _CustTable;
_parmId =  element.args().parm();
if(!element.args().caller())  
super(); 
}
else
{
info('DataSet Not Received'); 
}
}
6.       Override the init() of the datasource of the form table that we used  ie CustTable
public void init()
{
    Query               query;
    QueryBuildRange     queryBuildRangeProj;
switch(element.args().dataset())// get the table id sent by caller
{
case tablenum(CustTable):  // check the table if matches with this tableid
{
_AccountNum  =   element.args().parm();  // get the argument value
 query   = new Query();
queryBuildRangeProj = query.addDataSource(tablenum(CustTable)).addRange(fieldnum(CustTable,AccountNum));          // query build for the form to display
queryBuildRangeProj.value(_accountNum); // Criteria for the form
CustTable_ds.query(query); // execution of the query
break;
}
}
super(); //datasource  initialization on the form based on the criteria
}
7.       In the class declaration of the form
public class FormRun extends ObjectRun
{
    SysLookupMultiSelectCtrl msCtrl;
    AccountNum   _accountNum   ;
}
8.       

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Dear,
    How to get record in list page using Class declaration, please help me with code.

    Thanks,
    Aman Syed
    AX Technical Consultant

    ReplyDelete