Use of Category Hierarchy are a great way to classify our items ad other stuff. 

There can be scenarios in which you need to associate a particular entity (Item for instance) with Category Hierarchy. Once required, you will need the user to select a category (from the category hierarchy tree) against the entity which you are associating with category. 

Generally it would mean a lot of work. Make a custom form, drop the tree control, write complete tree populating logic, on user click event pass the category RecID to the parent form and so on. But this is not the way we develop on systems that are classified under the category of ERP :)

We are suppose to reuse the existing logic to save time and effort, and extend AX rather reinventing.

One of my friend, an expert in his domain ما شاء الله , Amir Nazim helped me in this. He gave me the correct reference of a perfectly reusable solution already applied on Purchase Order (Procurement module) form.

At the very bottom, we need a primary key based relation between your table and EcoResCategory table (The table that actually holds the definition of each category item). Hence on PurchLine Table, we have a relation with EcoResCategory table 

And on PurchTable Form, are the two overridden methods (at DataDource > PurchLine ) as follows;
  • lookupReference
  • resolveReference
Bodies of both the methods are provided for our reference;


    return EcoResCategory::lookupCategoryHierarchyRole(

public Common resolveReference(FormReferenceControl _formReferenceControl)
    return EcoResCategory::resolveCategoryHierarchyRole(

These two methods does the rest for us that is populating the tree, displaying it as a lookup and etc. Enjoy re-usability :)


Fahad said...

Thanks bro, this helped me in a customization. :)

Post a Comment