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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to do lookupReference and resolveReference via Chain of command?

(5) ShareShare
ReportReport
Posted on by 1,993
Hi,

I added an int64 "Category" field to "Table1" with Edt "EcoResCategoryId"
then i added this field to Form1

now i want to override the "lookupReference" and "resolveReference" methods of the field in the form datasource, in order to get the tree lookup.

but how to do it? 
When i first click on the drop down, it appears as normal lookup and everything appears without filtering the hierarchy role, then if i click on the drop down again, the tree lookup appears and it only shows the correct required data
 
[ExtensionOf(formDataFieldStr(Form1, Table1, Category))]
final class Form1FormDS_Extension
{
    public Common resolveReference(FormReferenceControl _formReferenceControl)
    {
        Common common;
        common = next resolveReference(_formReferenceControl);
        return EcoResCategory::resolveCategoryHierarchyRole(
                    _formReferenceControl,
                    EcoResCategoryNamedHierarchyRole::Retail);
    }

    public Common lookupReference(FormReferenceControl _formReferenceControl)
    {
        Common common;
        common = next lookupReference(_formReferenceControl);
        return EcoResCategory::lookupCategoryHierarchyRole(
                        _formReferenceControl,
                        EcoResCategoryNamedHierarchyRole::Retail);
    }
}
 
Categories:
I have the same question (0)
  • Suggested answer
    Waed Ayyad Profile Picture
    9,089 Super User 2026 Season 1 on at
    Hi.
     
     
     
    Thanks,
    Waed Ayyad
    If this helped, please mark it as "Verified" for others facing the same issue
     
  • .. Profile Picture
    1,993 on at
    My question was about CoC.
    The link you provided is not doing it via extensions.
  • Mesut Boztas Profile Picture
    26 on at
    Hi, please use the solution below.
    I had the same issue with my customization, and this approach has worked for me.
     
    Scenario:
    1- I have added a RefRecId field, which relates to the EcoResCategory table, to my table EngChgEcmProduct. The user can define the category of the item in this way.
     
    Solution:
     
    1- Add the refRecId extended field to your table ( in here, it is EngChgEcmProduct, ETGCategoryRefRecId)
    2- Add a new relation on your table EngChgEcmProduct with EcoResCategory (RecId).
    3- Add your new field to the form EngChgEcmHeaderDetails( Engineering change orders)
     
    4- Create a new code extension class (CoC) for the EngChgEcmHeaderDetails form and add a new lookup method to be used in the overriding of the lookupReference method of our new field.
    5- Create a new event handler class for the form datasource and override its OnInitialized method to link our new field with the new lookupReference method created in #4.
    6- Build the solution.
    7. Now, your new field will open the lookup form only once to show the category tree and will not be duplicated.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 658

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 468 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 333 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans