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 :
Microsoft Dynamics AX (Archived)

Reuse the lookup

(0) ShareShare
ReportReport
Posted on by

Hello,

I have a reference group control on a form which is having a lookupreference method on corresponding field in form datasource. 

Now i have a another form where i have the same reference group control and i want the same lookupreference method to be used there.

What should i do to avoid writing the same code in the lookupreference method of this new form? 

The same reference group control may be used in another forms gets created in future. everytime i don't want to write the same code in lookupreference method on each of those new forms.

Can a Class provide the solution for reuse of the code?

*This post is locked for comments

  • Suggested answer
    dolee Profile Picture
    11,279 on at

    For lookup method they are usually created at the Table.

    Then override the form > datasource > field's lookup method call that lookup method instead.

  • Suggested answer
    Rachit Profile Picture
    4,015 User Group Leader on at

    Hi VDY,

    Adding to Dominic's advise you can find similar example at \Forms\HcmGoal\Data Sources\HcmGoal\Fields\ClosedByManager\Methods\lookupReference().

    Regarding your question :"Everytime I don't want to write the same code in lookupreference method on each of those new forms.", if you do not want to use the standard framework lookup which comes on the basis of relations defined on the table then you will need to override the lookupReference method, otherwise you need to rethink about the relations between your table.

     

    Hope that helps.

     

     

  • Community Member Profile Picture
    on at

    Hi Rachit,

    I want to use standard framework lookup with a filter on it. Due to this filter, i have to override the lookupreference method and apply that filter in it.

    so i  want to avoid override this lookupreference method & writing filter code again & again on every new form where i use that reference group control.

  • Verified answer
    Martin Dráb Profile Picture
    241,460 Most Valuable Professional on at

    The solution is simple - extract your code to a separate method (typically placed on the table you're looking up). Your replacementLookup() method will have just a single line - a call to the table method.

  • Community Member Profile Picture
    on at

    Thanks Martin.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans