23 April 2019

How to override form data source field lookup method in D365FO , Form Extension control Lookup method in D365FO

Here find the GitHub Example
public class InventTestItemQualityGroup
{
    [FormDataSourceEventHandler(formDataSourceStr(InventTestItemQualityGroup, InventTestItemQualityGroup), FormDataSourceEventType::Initialized)]
    public static void InventTestItemQualityGroup_OnInitialized(FormDataSource sender, FormDataSourceEventArgs e)
    {
        var overrides = InventTestItemQualityGroup::construct();
     
        sender.object(fieldNum(InventTestItemQualityGroup, HHDFinishedGoods)).registerOverrideMethod(methodStr(FormDataObject, lookup),
            methodStr(InventTestItemQualityGroup,ItemId_OnLookup), overrides);
    }

    public void ItemId_OnLookup(FormStringControl _callingControl)
    {
        SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(InventTable), _callingControl);
        Query                 query = new Query();
        QueryBuildDataSource qbds,qbds2;
        QueryBuildLink            queryBuildLink;

        qbds= query.addDataSource(tableNum(InventTable));
        qbds.addRange(fieldNum(InventTable, ItemId));
        qbds2 = qbds.addDataSource(tablenum(InventItemGroupItem));   

        qbds2.joinMode(JoinMode::InnerJoin);//
        qbds2.addLink(fieldnum(InventTable, ItemId),fieldnum(InventItemGroupItem, ItemId));//
        qbds2.addLink(fieldNum(InventTable, DataAreaId),fieldnum(InventItemGroupItem, ItemDataAreaId));//
        qbds2.addRange( fieldNum( InventItemGroupItem, ItemGroupId)).value(queryValue(InventParameters::find().HHDItemGroup));

        sysTableLookup.parmQuery(query);

        sysTableLookup.addLookupfield(fieldNum(InventTable, ItemId));
        sysTableLookup.addLookupfield(fieldNum(InventTable, NameAlias));     
        sysTableLookup.addLookupfield(fieldNum( InventItemGroupItem, ItemGroupId));

        sysTableLookup.performFormLookup();
    }

    public static InventTestItemQualityGroup construct()
    {
        return new InventTestItemQualityGroup();
    }

}

No comments:

Post a Comment

Give me the commetns and solutions

Ledger Voucher creation Framework and x++ code to create ledger voucher

 Please click her for MS reference file Below is the out of the box example reference and code. SalesInvoiceJournalPostSubBill_Extension-...