Fetch Hierarchical data for Product Category in Dynamics 365 Operations
Introduction:
In this blog article, we will see how we can fetch hierarchical data using X++.
How to fetch?
We will take a scenario where we will pass a category hierarchy and will fetch all categories of that hierarchy and its child category.
public class ProductCategoryHierarchy { EcoResCategory category; public void ParentCategory() { while select category where category.CategoryHierarchy == “Brands” { //code this.getChildrenCategory(category.RecId); } } /// <summary> /// get categories of child product /// </summary> public void getChildrenCategory(EcoResCategoryId ParentCategory) { while select category where category.ParentCategory == ParentCategory { //code this.getChildrenCategory(category.RecId); } } }