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();
    }



Support The Author

 If you found value in what I share, I've set up a Buy Me a Coffee page as a way to show your support.

Buy Me a Coffee

Post a Comment


All Comments


No comments. Be the first one to comment on this post.

Search

About

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

Authors are allowed to set their own "buy me a coffee" link.
Join us.

Blog Tags