axaptamicrosoft-dynamicsx++dynamics-ax-2012ax

check Product procurement category hierarchy


I m working with dynamics ax 2012 and i m looking for a fonction that verifie if a product is exist in the procurement category hierarchy This listepage Product Information Management -> Common -> Products -> Released Product show list of product released in the actionpane product ,we have button validate ; when i select a record in the grid control and clicked in the button validate

i should verifie if the procurement category is attached to this product , there is no error ;if no procurement category is attached to this product ,it must display an arror message

Apparently , the procurement category is a category hierarchy which I will go look for if the product is attached for this category, How can i create a fonction to search in the category hierarchy

Can anyone help me?


Solution

  • You need two tables to do that validation:

    1. Table EcoResProductCategory tells who what categories and category hierarchies a product has.
    2. Table EcoResCategoryHierarchyRole tells you what role a category hierarchy has. The role itself is the enum EcoResCategorynamedHierarchyRole and there you can find the element Procurement.

    Now you can combine these two tables in a query that checks if the product has a category in a category hierarchy that has the Procurement role.