web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Form Data Source Field Lookup Method Override in D365FO using COC Extension

(0) ShareShare
ReportReport
Posted on by 25

Hi Experts,

I want to override Form Data Source Field Lookup Method using COC instead of event handlers because user can manually edit field by add column option.

Any one guide me what is wrong here in my code. Debugger does not hit on lookup.

[ExtensionOf(formDataFieldStr(SalesTable, SalesLine, TaxGroup))]
final class SalesTableForm_Extension
{
    public void lookup(FormControl _formControl, str _filterStr)
    {
        Query                           query = new Query();
        QueryBuildDataSource            qbds;
        SysTableLookup                  sysTablelookup;

        next lookup(_formControl, _filterStr);

        sysTablelookup = SysTableLookup::newParameters(tableNum(TaxGroupHeading), _formControl);

        // Filter lookup to only show sales tax Groups
        query.addDataSource(tableNum(TaxGroupHeading)).addRange(fieldNum(TaxGroupHeading, IsSales)).value(queryValue(NoYes::Yes));

        // Sort the lookup by TaxGroup
        query.dataSourceTable(tableNum(TaxGroupHeading)).addOrderByField(fieldNum(TaxGroupHeading, TaxGroup), SortOrder::Ascending);

        sysTablelookup.parmQuery(query);

        sysTablelookup.addLookupfield(fieldNum(TaxGroupHeading, TaxGroup));
        sysTablelookup.addLookupfield(fieldNum(TaxGroupHeading, TaxGroupName));

        sysTablelookup.performFormLookup();

       
    }

}

I have the same question (0)
  • FaranBaig Profile Picture
    25 on at
    RE: Form Data Source Field Lookup Method Override in D365FO using COC Extension

    Hi Nikolaos,

    I tried Infolog, but not get printed.

    Also Form does not contain that lookup method on datasource field by default. I think that is why debugger and Infolog not working.

  • Verified answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Form Data Source Field Lookup Method Override in D365FO using COC Extension

    Perhaps your debugger settings are incorrect.

    If you try to print something to infolog before calling next lookup, does it get printed to infolog?

    Also, please be aware that you can never use CoC to override any methods (unless Replaceable attribute is specified in the original method).

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Sohaib Cheema Profile Picture

Sohaib Cheema 789 User Group Leader

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 607 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 497 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans