Override form control Lookup using extensions

Expand controll Events node and right click on OnLookup and select Copy event handlr method.
To supress standard lookup method and following warning message:
More than one form was opened at once for the lookup control.
Use following code:
        FormControlCancelableSuperEventArgs ce = e as FormControlCancelableSuperEventArgs;
        ce.CancelSuperCall();
Full lookup method:
    [FormControlEventHandler(formControlStr(AssetParameters, VKInterfacesGroup_VKFixedAssetJournalNameId), FormControlEventType::Lookup)]
    public static void VKInterfacesGroup_VKFixedAssetJournalNameId_OnLookup(FormControl sender, FormControlEventArgs e)
    {
        Query query = new Query();
        QueryBuildDataSource queryBuildDataSource;
        QueryBuildRange queryBuildRange;
    
        SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(InventJournalName), sender);
    
        sysTableLookup.addLookupField(fieldNum(InventJournalName, JournalNameId));
        sysTableLookup.addLookupField(fieldNum(InventJournalName, Description));
    
        queryBuildDataSource = query.addDataSource(tableNum(InventJournalName));
    
        queryBuildRange = queryBuildDataSource.addRange(fieldNum(InventJournalName, JournalType));
        queryBuildRange.value(SysQuery::value(InventJournalType::Asset));
    
        sysTableLookup.parmQuery(query);
    
        sysTableLookup.performFormLookup();

        FormControlCancelableSuperEventArgs ce = e as FormControlCancelableSuperEventArgs;
        ce.CancelSuperCall();
    }


Search

About

DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics AX.

Authors are allowed to set their own AdSense units.
Join us.

Blog Tags