Multiple table fields custom lookup in AX 2012

Hi Friends,

Today, in this post we are going to share how you can add multiple tables fields custom lookup in AX 2012.

Let's take a scenario to understand the requirement first...

We need to make custom lookup for Product Number from EcoResProduct table and Item Number from Invent Table.

For this type of requirement first create a query by joining these two tables and then add query and fields in view.

Steps to follow:

1. Create a new query and drag and drop InventTable from AOT in it.
2. Set the fields property Dynamic = No and add ItemId in fields.
3. In InventTable data source drag and drop EcoResProduct table from AOT.
4. Set the fields property Dynamic = No and add DisplayProductNumber in it.
5. Set the Fetch mode = 1:1 and Relations = Yes for EcoResProduct data source property.
6. Query is ready to use to add in View. Let's create a view.



7. Create a view and add your query in it.
8. Add fields which you want to show in the view.



9. Write custom lookup logic on form control like below. If you don't know how to create custom lookup click here.
10. Done.



public void lookup()
{
    Query                   query = new Query();
    QueryBuildDataSource    qbds;
    SysTableLookup          sysTableLookup = sysTableLookup::newParameters(tableNum(PKA_IntercompanyProductSetup), this);
    ;

    sysTableLookup.addLookupField(fieldNum(PKA_IntercompanyProductSetup, DisplayProductNumber));
    sysTableLookup.addLookupField(fieldNum(PKA_IntercompanyProductSetup, ItemId));

    qbds = query.addDataSource(tableNum(PKA_IntercompanyProductSetup));

    sysTableLookup.parmQuery(query);

    sysTableLookup.performFormLookup();
}


We hope this solution helped you to add multiple table fields 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:
6-Apr-2020

Happy Learning !!

Comments

Popular posts from this blog

[Solved] : Error: String or binary data would be truncated. Cannot execute a data definition language command on Vendor (VendLedgerReconciliationTmp)

AX 2012 - Command prompt compilation / AxBuild.exe for Parallel Compile on AOS of X++ to P-code / Parallel Compilation

AX 2012 - How to send SSRS report in email as an attachment using X++

AX 2012 - How to stop AOS when services got stuck at stopping status

AX 2012 - How to make a form field mandatory

Error: There was no endpoint listening at net.tcp://your_server_name:8201/Dynamics AX/Services…

Fetch vendor address using X++ in AX 2012

AX 2012 - How to print current date and time on SSRS Report

[Error] - Error in unit of amount in currency KES. Must be rounded to 0.01 | The unit of 37.563.5343100000000000 KES being posted to account 32710001-- is outside the current penny rounding threshold | Posting has been canceled

[Solved] : AX 2012 - No connection could be made because the target machine actively refused it 192.168.10.249:8201