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, ...
Suggested answer

how to call lookup reference method in form level

(0) ShareShare
ReportReport
Posted on by 1,931

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();
    }

}

I have the same question (0)
  • GirishS Profile Picture
    27,825 Moderator 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.

  • .. Profile Picture
    1,931 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.

  • Suggested answer
    GirishS Profile Picture
    27,825 Moderator 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,931 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?

  • GirishS Profile Picture
    27,825 Moderator 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,931 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
    27,825 Moderator 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.

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

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

#1
André Arnaud de Calavon Profile Picture

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

#2
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 588

#3
Martin Dráb Profile Picture

Martin Dráb 542 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans