Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

how to call lookup reference method in form level

(0) ShareShare
ReportReport
Posted on by 1,333

Hi,

I'm getting an error that lookupReference is not a valid method -- this code would have worked if it was a string control and I used lookup method. But why this one doesn't work. why?
This field is bounded to a dataSource

[ExtensionOf(formstr(XXParameters))]
 final class ParametersFormXX_Extension
{
    public void init()
    {
        next init();

        XXFiled_XXField.RegisterOverrideMethod(methodStr(FormReferenceGroupControl, lookupReference),
            formMethodStr(XXParameters, xxField_OnLookup));
    }

    public Common xxSiteDimensionAttribute_OnLookup(FormReferenceControl _formReferenceControl)
    {
        SysReferenceTableLookup sysReferenceTableLookup;
        Query                   query;
        QueryBuildDataSource    qbdsDAttribute;
        QueryBuildDataSource    qbdsD;
           
        sysReferenceTableLookup = SysReferenceTableLookup::newParameters(tableNum(Table1), _formReferenceControl);
       //code
        sysReferenceTableLookup.parmQuery(query);

        return sysReferenceTableLookup.performFormLookup();
    }

}

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: how to call lookup reference method in form level

    If that is the case no need to create a new method, add whole logic inside the lookup event handler method.

    Also I don't think adding new method in event handler throw bp warning. You can add a new method in the event handler class and check whether its throwing any bp warning.

    Thanks,

    Girish S.

  • .. Profile Picture
    .. 1,333 on at
    RE: how to call lookup reference method in form level

    Hi Girish,

    But I thought event handler class should only contain event handler methods? So I'm not sure if it's a good practice to create a new method in event handler class that is not related to event handler methods

    Also why the code i mentioned in the question works for formStringControl look up method and doesn't work for reference group control reference lookup method?

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: how to call lookup reference method in form level

    Yes you need to create new class and paste the copied event handler there.

    Yeah you can call the form method from the event handler class. But in the event handler class you need to get the form run first and then call the lookup method.

    Also instead of creating COC for the form and adding new method, you can directly create an event handler class and add your lookup query directly there. So instead of creating 2 class you can restrict it to one class.

    Thanks,

    Girish S.

  • .. Profile Picture
    .. 1,333 on at
    RE: how to call lookup reference method in form level

    Hi Girish,

    Based on the link you shared. Where is the private static method created? Is it in the event handler or another class? It's another new class right?

    If it's a new class..why not create a method on the form instead and call it in event handler? Would it be possible?

  • Suggested answer
    GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: how to call lookup reference method in form level

    Oh, if its a form control then you can go for lookup event handler.

    Code you have written will do the same thing as lookup event handler will do. So its better to go with writing lookup event handler.

    Refer to the below blog for writing lookup event handler.

    http://thinkinginax.blogspot.com/2019/03/reference-group-control-lookup-in-d365.html?m=1

    Thanks,

    Girish S.

  • .. Profile Picture
    .. 1,333 on at
    RE: how to call lookup reference method in form level

    Hi Girish,

    It's a reference group that's why I'm calling lookup reference.

    What I meant that this way will work it was a lookup method with string control.

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: how to call lookup reference method in form level

    Hi IntegrationBeginner,

    What type of control is XXSiteDimension?

    If its a string control then you need to use lookup method only.

    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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,234 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,994 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans