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.
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.
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.
Yes, you need to override the lookup event handler wherever you need.
Thanks,
Girish S.
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,
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.
André Arnaud de Cal...
291,969
Super User 2025 Season 1
Martin Dráb
230,842
Most Valuable Professional
nmaenpaa
101,156