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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

D365/AX7 Event of lookupreference is missing

(0) ShareShare
ReportReport
Posted on by 2,546

Hello,

I am doing a customisation in form PurchCreateOrder.

I want to give vendor address lookup during PO Creation.I have added one field int64 DeliveryPostaladdress in PurchTable and added a relation with LogisticsPostalAddress.

Now I added a reference group in PurchCreateOrder.

now I want to customise the method lookupreference() .

but I am not seeing any event related to lookupreference()

I have the same question (0)
  • Sergei Minozhenko Profile Picture
    23,093 on at

    Hi

    Have you checked if you can use CoC in this case?

    BR, Sergey

  • Piyush Adhikari Profile Picture
    2,546 on at

    Its is impossible to use COC as we cannot create method in base FORM

    I am using         SysReferenceTableLookup.

    once it will be achieved I will update here

    class AcxPurchCreateOrderFormEvents

    {

       /// <summary>

       ///

       /// </summary>

       /// <param name="sender"></param>

       /// <param name="e"></param>

       [FormControlEventHandler(formControlStr(PurchCreateOrder, PurchTable_AcxDeliveryPostalAddressVend), FormControlEventType::Lookup)]

       public static void PurchTable_AcxDeliveryPostalAddressVend_OnLookup(FormControl sender, FormControlEventArgs e)

       {

           VendTable   vendTable;

           Common  common;

           PurchTable  purchTable = sender.formRun().dataSource(formDataSourceStr(PurchCreateOrder,PurchTable )).cursor();

           VendTable = VendTable::find(purchTable.OrderAccount);

           SysReferenceTableLookup           sysTableLookup = SysReferenceTableLookup ::newParameters(tableNum(LogisticsPostalAddress),sender);

           Query                   q   = new Query();

           QueryBuildDataSource    qbds;

           qbds   = q.addDataSource(tableNum(LogisticsPostalAddress));

           sysTableLookup.addLookupfield(fieldNum(LogisticsPostalAddress, Location));

           sysTableLookup.addLookupfield(fieldNum(LogisticsPostalAddress, Address));

           sysTableLookup.parmQuery(q);

           sysTableLookup.performFormLookup();

       }

    }

  • Sergei Minozhenko Profile Picture
    23,093 on at

    Hi,

    CoC works for form control methods even if they don't exist, maybe not all, but lookupReference works.

    BR, Sergey

  • Piyush Adhikari Profile Picture
    2,546 on at

    can you share me some code? I would be really grateful I am trying but not able to do COC of lookup reference.

  • Sergei Minozhenko Profile Picture
    23,093 on at

    Hi,

    I used standard control and don't know if it will work with control added via an extension to the form.

    [ExtensionOf(formControlStr(PurchCreateOrder, PurchTable_DeliveryPostalAddress))]

    public final class PurchCreateOrderForm_DeliveryPostalAddress_Extension

    {

       public Common lookupReference()

       {

           Common ret;

           ret = next lookupReference();

           return ret;

       }

    }

  • Suggested answer
    Evaldas Profile Picture
    1,800 on at

    Neither events nor CoC will help in lookupReference case. You need to use registerOverrideMethod to do the trick.

    As events and CoC will not prevent from standard lookup/lookupReference from showing.

  • Sergei Minozhenko Profile Picture
    23,093 on at

    Hi Evaldas

    Lookup event args class supports CancelSuperCall method, so it's possible to prevent standard lookup. With CoC indeed it's not possible.

    BR, Sergey

  • Evaldas Profile Picture
    1,800 on at

    Oh! I forgot about that, thanks! :)

  • Sona Jee Profile Picture
    436 on at

    Hi Sergei,

    In below code how to call cancelsupercall method, I have similar requirement but not able to call cancelsupercall in COC .

    [ExtensionOf(formControlStr(PurchCreateOrder, PurchTable_DeliveryPostalAddress))]

    public final class PurchCreateOrderForm_DeliveryPostalAddress_Extension

    {

      public Common lookupReference()

      {

          Common ret;

          ret = next lookupReference();

          return ret;

      }

    }

    Thank you

  • Suggested answer
    Martin Dráb Profile Picture
    237,803 Most Valuable Professional on at

    You can use the Looukup event even in this case. For example:

    [FormControlEventHandler(formControlStr(MyWorker, MyWorker_HcmWorkerRecId), FormControlEventType::Lookup)]
    public static void MyWorker_HcmWorkerRecId_OnLookup(FormControl sender, FormControlEventArgs e)
    {
        MyClass::createLookup(sender);
    
        FormControlCancelableSuperEventArgs cancelableArgs = e as FormControlCancelableSuperEventArgs;
        cancelableArgs.CancelSuperCall();
    }
    
    private static void createLookup(FormReferenceGroupControl _ctrl)
    {
        SysReferenceTableLookup sysTableLookup = SysReferenceTableLookup::newParameters(tablenum(HcmWorker), _ctrl);
        Query                   query = new Query();
    
        sysTableLookup.addLookupfield(fieldNum(HcmWorker, PersonnelNumber));
       
        query.addDataSource(tablenum(HcmWorker));
        sysTableLookup.parmQuery(query);
        sysTableLookup.performFormLookup();
    }

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans