LOOKUP FIELD RANGES IN MICROSOFT DYNAMICS AX 2012:
Override the control for eg. “Fld2_1” in a dialog box.
public void Fld2_1_Lookup()
{
SysTableLookup sysTableLookup;
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange queryBuildRange;
Query query;
FormStringControl _control;
;
sysTableLookup = SysTableLookup::newParameters(tablenum(CustTable),dialogCustAccount.control());
sysTableLookup.addLookupfield(fieldnum(CustTable, AccountNum));
sysTableLookup.addLookupfield(fieldnum(CustTable, CustGroup));
query = new Query();
queryBuildDataSource = query.addDataSource(tablenum(CustTable));
queryBuildRange = queryBuildDataSource.addRange(fieldnum(CustTable, custGroup));
queryBuildRange.value(dialogCustGroupId.value());
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
Now override the “dialogPostRun()” method from the override methods and the code after super() call as shown below.
public void dialogPostRun(DialogRunbase dialog)
{
super(dialog);
dialog.formRun().controlMethodOverload(true);
dialog.formRun().controlMethodOverloadObject(this);
}
This will make the second lookup filter by the customer number.
No comments:
Post a Comment