Quantcast
Channel: Microsoft Dynamics 365 Community
Viewing all articles
Browse latest Browse all 64797

Show methods in AX lookups

$
0
0
This sample code is used to show Customer Name in lookup, In AX 2009 we had name field in CustTable but now its moved to DirPartyTable. We still have name() in CustTable which we can use to display name in lookups.


AX 2009
client static void lookupInterCompanyItemId(FormStringControl   lookupCtrl, DataAreaId _dataAreaId = "")
{
    SysTableLookup          sysTableLookup = SysTableLookup::newParameters(tablenum(InventTable), lookupCtrl);
    Query                   query = new Query();
    QueryBuildDataSource    qbds = query.addDataSource(tablenum(InventTable));
    ;

    sysTableLookup.addLookupfield(fieldnum(InventTable, ItemId));
    sysTableLookup.addLookupfield(fieldnum(InventTable, ItemName));
    sysTableLookup.addLookupfield(fieldnum(InventTable, ItemGroupId));
    sysTableLookup.addLookupfield(fieldnum(InventTable, ItemType));

    if(_dataAreaId)
        qbds.company(_dataAreaId);

    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();

}

AX 2012
 client static void lookupInterCompanyItemId(FormStringControl   lookupCtrl, DataAreaId _dataAreaId = "")
{
    SysTableLookup          sysTableLookup = SysTableLookup::newParameters(tablenum(InventTable), lookupCtrl);
    Query                   query = new Query();
    QueryBuildDataSource    qbds = query.addDataSource(tablenum(InventTable));
    ;

    sysTableLookup.addLookupfield(fieldnum(InventTable, ItemId));
    sysTableLookup.addLookupfield(fieldnum(InventTable, NameAlias));
    sysTableLookup.addLookupMethod(tableMethodStr(InventTable,itemGroupId));
    sysTableLookup.addLookupfield(fieldnum(InventTable, ItemType));

    if(_dataAreaId)
        qbds.company(_dataAreaId);

    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();
}

Viewing all articles
Browse latest Browse all 64797

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>