How to add multiple datasource in custom lookup in dynamics ax

Description:-

In this article we will see about how to add multi-table in custom lookup. here is the job to add multi-table in custom lookup.

Job:-

public void lookup()
{
    Query                   query = new Query();
    QueryBuildDataSource    qbdsItem;
    QueryBuildDataSource    qbdsJoin,qbdsJoin1,qbdsJoin2,qbdsJoin3;
    //QueryBuildDataSource    qbdsInventItemLocation;
    QueryBuildRange         qbr,qbrModuleType;
    SysMultiTableLookup     sysTableLookup;
    ;
    qbdsItem = query.addDataSource(tableNum(InventTable));
    qbdsJoin= qbdsItem.addDataSource( tableNum(EcoResProduct),"EcoResProduct");
    qbdsJoin.relations( false);
    qbdsJoin.fields().dynamic(NoYes::Yes);
    qbdsJoin.addLink( fieldNum(InventTable, ItemId), fieldNum(EcoResProduct, DisplayProductNumber));
    qbdsJoin.joinMode(JoinMode::InnerJoin);

    qbdsJoin1= qbdsJoin.addDataSource( tableNum(EcoResProductMaster));
    qbdsJoin1.relations( false);
    qbdsJoin1.fields().dynamic(NoYes::Yes);
    qbdsJoin1.addLink( fieldNum(EcoResProduct, RecId), fieldNum(EcoResProductMaster, RecId));
    qbdsJoin1.joinMode(JoinMode::InnerJoin);

    qbdsJoin2= qbdsJoin1.addDataSource( tableNum(EcoResProductMasterSize));
    qbdsJoin2.relations( false);
    qbdsJoin2.fields().dynamic(NoYes::Yes);
    qbdsJoin2.addLink( fieldNum(EcoResProductMaster, RecId), fieldNum(EcoResProductMasterSize, SizeProductMaster));
    qbdsJoin2.joinMode(JoinMode::InnerJoin);

    qbdsJoin3= qbdsJoin2.addDataSource( tableNum(EcoResSize));
    qbdsJoin3.relations( false);
    qbdsJoin3.fields().dynamic(NoYes::Yes);
    qbdsJoin3.addLink( fieldNum(EcoResProductMasterSize, Size), fieldNum(EcoResSize, RecId));
    qbdsJoin3.joinMode(JoinMode::InnerJoin);
    //qbr=qbdsJoin.addRange(fieldNum(InventModelGroupItem,ModelGroupId));
    //qbr.value('FIFO');
    //qbr=qbdsJoin.addRange(fieldNum(InventTable,ItemId));
    //qbr.value(A_Test_ItemId.valueStr());


    sysTableLookup = SysMultiTableLookup::newParameters(this, query);

    sysTableLookup.addLookupField(fieldNum(InventTable, ItemId));
    //sysTableLookup.addLookupField(fieldNum(InventTable, ItemName));
    //sysTableLookup.addLookupMethod(tableMethodStr(InventTable, ConfigActive), 1, "Is configuration active?");
    sysTableLookup.addLookupField(fieldNum(EcoResSize,Name), 1, false, "Item Size");
    sysTableLookup.performFormLookup();
}

Related Posts

Previous
Next Post »

Thanks for comments.....