preloader-matrix

Alfasith

Passing the records between the forms Dynamic AX

Hi
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
voidClicked()
{
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 voidinit()
{
parmid      _parmId;
CustTable   _CustTable;
//     DictTable   _dictTable;    FormBuildDataSource   _ds;    FormBuildGridControl frmGrid; // These are for dynamicForm creation so leave it
_parmId =  element.args().parm(); // Getting the argument value from the Caller
//info(int2str(element.args().record().TableId));
if(!element.args().caller())   // Check the form is called by caller or directly, if directly it throw error
throw error(‘Cant Run Directly’);
if(element.args().record().TableId == tablenum(CustTable))   // check if the sent Table and the Current form table are equal or not
{
//        _EmplTable = element.args().record();  // Assign the Received Table name to Local Variable
//_dictTable = new DictTable(element.args().record().TableId);  // leave it , is used for Dynamic Form Creation
//_ds = form.addDataSource(_dictTable.name());  // leave it , is used for Dynamic Form Creation
//_ds.table(_dictTable.id());   // leave it , is used for Dynamic Form Creation
//frmGrid = form.addControl(FormControlType::Grid, “Grid”);   // leave it , is used for Dynamic Form Creation
//frmGrid.dataSource(_ds.name());   // leave it , is used for Dynamic Form Creation
//info(strfmt(“%1     %2″,_EmplTable.EmplId,_EmplTable.DEL_Name));
//frmGrid.addDataField(_ds.id(),fieldnum(EmplTable, DEL_Name));  // leave it , is used for Dynamic Form Creation
//        EmplTable_EmplId.dataSource(_EmplTable);   // leave it , is used for Dynamic Form Creation
//        EmplTable_EmplId.dataField(fieldnum(EmplTable,EmplID));   // leave it , is used for Dynamic Form Creation
//        EmplTable_DEL_Name.dataSource(_EmplTable);   // leave it , is used for Dynamic Form Creation
//        EmplTable_DEL_Name.dataField(fieldnum(EmplTable,EmplId));  // leave it , is used for Dynamic Form Creation
//        EmplTable_DEL_Email.dataSource(_EmplTable);   // leave it , is used for Dynamic Form Creation
//        EmplTable_DEL_Email.dataField(fieldnum(EmplTable,EmplId));   // leave it , is used for Dynamic Form Creation
super();  // Form Initialization
}
else
{
info(‘DataSet Not Received’);  // throw error
}
}
6.       Override the init() of the datasource of the form table that we used  ie CustTable
publicvoid init()
{
    Query               query;
    QueryBuildRange     queryBuildRangeProj;
switch(element.args().dataset())// get the table id sent by caller
{
casetablenum(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
publicclass FormRun extends ObjectRun
{
    SysLookupMultiSelectCtrl msCtrl;
    AccountNum   _accountNum   ;
}
8.       

 

Share on email
Share on facebook
Share on twitter
Share on linkedin
Share on pinterest

2 Responses

Leave a Reply

Your email address will not be published.