I'm working with RetailPeriodicDiscount form, which is the form for Discounts, Mix and Match Discount, etc...

In the Product selection lookup, I need to add the respective Item Number.

Reasons behind this are:

1. Product number is not equal to Item number.

2. Users are only familiar with item number rather than product number. So they need to know which item numbers are for the product they're selecting from the lookup.

User prefer the item numbers to be sort-able  and filterable, so I'd like to override the standard lookup form data source which is EcoresProduct Table. I created a view containing the Product number, Search name, Product type and Item number and intended this view to be my lookup data source.

I use the RegisterOverrideMethod approach to implement my custom lookup as below;

public class RetailPeriodicDiscountOverrides

    /// <summary>
    /// Constructs a new instance of <c>RetailPeriodicDiscountOverrides</c> class.
    /// </summary>
    /// <returns>
    /// A <c>RetailPeriodicDiscountOverrides</c> class.
    /// </returns>
    public static RetailPeriodicDiscountOverrides construct()
        return new RetailPeriodicDiscountOverrides();

    /// <summary>
    /// Provides a lookup for the <c>EcoResProductItemView</c> table
    /// </summary>
    /// <param name = "_callingControl">
    /// The form string control object with which to perform the lookup.
    /// </param>
    public void productViewLookup(FormReferenceGroupControl _callingControl)
        Query query = new Query();
        QueryBuildDataSource DS;
        //SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(EcoResProductItemView), _callingControl);
        SysReferenceTableLookup sysTableLookup = SysReferenceTableLookup::newParameters(tableNum(EcoResProductItemView), _callingControl);
        sysTableLookup.addLookupfield(fieldNum(EcoResProductItemView, DisplayProductNumber));
        sysTableLookup.addLookupfield(fieldNum(EcoResProductItemView, SearchName));
        sysTableLookup.addLookupfield(fieldNum(EcoResProductItemView, ItemId));
        DS = query.addDataSource(tableNum(EcoResProductItemView));




final class RetailPeriodicDiscount_Extension
    /// <summary>
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    [FormDataSourceEventHandler(formDataSourceStr(RetailPeriodicDiscount, RetailGroupMemberLine), FormDataSourceEventType::Initialized)]
    public static void RetailGroupMemberLine_OnInitialized(FormDataSource sender, FormDataSourceEventArgs e)
        RetailPeriodicDiscountOverrides overrides = RetailPeriodicDiscountOverrides::construct();
        FormRun formrun = sender.formRun();
        FormReferenceGroupControl product =  formrun.design(0).controlName('RetailGroupMemberLine_Product');
        product.registerOverrideMethod(methodStr(FormDataObject, lookup),
            methodStr(RetailPeriodicDiscountOverrides, productViewLookup), overrides);



But when I perform the lookup, I got this error:

Could not process the lookupRecord value on the Args instance.
The table 'EcoResProduct' does not exist as a root FormDataSource for the form

I understand that I have to use EcoresProduct as my lookup data source to resolve this error, but then I won't get sort-able/filterable item number using display method. Plus, there's this bug about custom display method not displaying on custom lookup like this post here. I'm working on version 10.0.4 PU28 and the bug seems to be still there.

Is it possible to completely override this standard product lookup and use a completely different data source for my custom lookup?

Thank you.