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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

EventHandler on lookup method defined in table

(0) ShareShare
ReportReport
Posted on by 87

Hello,

I am quite new (still) on D365.

I know that is possible to override forms lookup methods using event handlers. But, what happens when different forms call the same lookup defined in one table?

[PreHandlerFor(tableStr(SalesQuotationTable), tableMethodStr(SalesQuotationTable, lookupOpportunityId))]
public static void lookupOpportunityId(XppPrePostArgs args)
{
    //Some code
}

In this case, i don't see how to get the formcontrol. Usually, overriding a lookup method in form looks like:

 [FormControlEventHandler(formControlStr(formName, formControl), FormControlEventType::Lookup)]
public static void methodName(FormControl sender, FormControlEventArgs e)
{
    //Some code
}

Where i have the sender and a FormControlEventArgs, so i have the control, also i can cancel the double perform lookup.

It is possible to override the lookup in my first scenario? i did not find th way.

Thanks in advance,

Eisenberk.

I have the same question (0)
  • Verified answer
    GirishS Profile Picture
    27,833 Moderator on at

    Hi Eisenberk,

    You create a table method with argument as FormControl, ControlValue. Later you can call that method on the lookup event handler.

    Create a common lookup method.

    public static common Lookup(FormReferenceControl _formReferenceControl,
                                    HcmWorkerRecId _workerRecid)
                                            
    {
        //add code for lookup method with query build datasource and query build range.
        return tableLookup.performFormLookup;
    }

    Now call this method on the lookup event handler.

    [FormControlEventHandler(formControlStr(formName, formControl), FormControlEventType::Lookup)]
    public static void methodName(FormControl sender, FormControlEventArgs e)
    {
        Call the lookup method from the table.
        TableName::lookup(sender,HcmWorkerRecid);
        FormControlCancelableSuperEventArgs  cancelSuperEventArgs = e as FormControlCancelableSuperEventArgs;
        cancelSuperEventArgs.CancelSuperCall();
    }

    Thanks,

    Girish S.

  • Eisenberk Profile Picture
    87 on at

    Hi Girish,

    In your example, I guess i have to override the look event handler in each form that i call the table lookup method, right?

    Thanks,

  • GirishS Profile Picture
    27,833 Moderator on at

    Yes, you need to override the lookup event handler wherever you need.

    Thanks,

    Girish S.

  • Mohit Rampal Profile Picture
    12,565 Moderator on at

    Hi, I don't think your overriding table lookup in your first scenario is possible. Your second scenario is possible and many blogs available for it.

  • GirishS Profile Picture
    27,833 Moderator on at

    Creating common lookup method in table and calling everywhere in the lookup event handler is possible. But you cant override the lookup method at table level.

    Thanks,

    Girish S.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 510 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 399

#3
Adis Profile Picture

Adis 251 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans