Custom lookup in AX 2012
Dear Friends,
Today, in this post we are going to share how you can add custom lookup in your form control in AX 2012.
Let's start...
1) In the AOT, expand Forms, expand the form, expand Designs, right-click Design. Add or drag a new control in the design section of form.
Example: You can drag a string field from your form data source.
2) Expand the control on which you want to add the custom lookup, right-click Methods, click Override method, and then click lookup. The lookup method opens in the code editor.
3) Copy paste the below code.
4) Open the form and check for custom lookup in that.
Note: For more information on this article click here.
We hope this solution helped you to add custom lookup on form control using X++ in AX 2012. Please comment your valuable feedback for this article...
Author:
Chirag Gupta
Microsoft Dynamics D365/AX 2012
Senior Technical Consultant at IBM Bangalore
Date:
4-Apr-2020
Happy Learning !!
Today, in this post we are going to share how you can add custom lookup in your form control in AX 2012.
Let's start...
1) In the AOT, expand Forms, expand the form, expand Designs, right-click Design. Add or drag a new control in the design section of form.
Example: You can drag a string field from your form data source.
2) Expand the control on which you want to add the custom lookup, right-click Methods, click Override method, and then click lookup. The lookup method opens in the code editor.
3) Copy paste the below code.
public void lookup()
{
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange queryBuildRange;
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(custTable), this);
sysTableLookup.addLookupField(fieldNum(CustTable, AccountNum));
sysTableLookup.addLookupField(fieldNum(CustTable, CustGroup));
queryBuildDataSource = query.addDataSource(tableNum(CustTable));
queryBuildRange = queryBuildDataSource.addRange(fieldNum(CustTable, CustGroup));
queryBuildRange.value('40');
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
//super();
}
Note: When you override the lookup method, comment out the call to super. If you do not comment out the call to super, the standard lookup form might appear.{
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange queryBuildRange;
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(custTable), this);
sysTableLookup.addLookupField(fieldNum(CustTable, AccountNum));
sysTableLookup.addLookupField(fieldNum(CustTable, CustGroup));
queryBuildDataSource = query.addDataSource(tableNum(CustTable));
queryBuildRange = queryBuildDataSource.addRange(fieldNum(CustTable, CustGroup));
queryBuildRange.value('40');
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
//super();
}
4) Open the form and check for custom lookup in that.
Note: For more information on this article click here.
We hope this solution helped you to add custom lookup on form control using X++ in AX 2012. Please comment your valuable feedback for this article...
Author:
Chirag Gupta
Microsoft Dynamics D365/AX 2012
Senior Technical Consultant at IBM Bangalore
Date:
4-Apr-2020
Happy Learning !!
Comments
Post a Comment