Pass Selected Record To New Form Dynamic AX
Trainee: Song Thanh Nghia
Step1. Create a form with datasource as CustTable and design a form, then we have a grid with the same datasource. And add button to override click and function in this to pass argrument.
Step2. Code in Override click
void Clicked()
{
Args _args;
FormRun _formRun;
AccountNum _accountNum;
;
_accountNum = CustTable.AccountNum; // Selected data to pass in args
_args = new Args(); // creating a object for args class
_args.name(formstr(CustomerSelectionRecordsA)); // Name of display form
_args.caller(this); //Caller form
_args.parm(_accountNum); // Parm record to new form
_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
}
Step3. Create another form same old form
Step4. In new form overide init form
public void init()
{
parmid _parmId;
CustTable _CustTable;
_parmId = element.args().parm();
if(!element.args().caller())
{
super();
}
else
{
info('DataSet Not Received');
}
}
Step5. Overide Init datasource
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
}
Step6. In the class declaration of the form
public class FormRun extends ObjectRun
{
SysLookupMultiSelectCtrl msCtrl;
AccountNum _accountNum ;
}
And then is result
Learn online
No comments:
Post a Comment