class GetCategoryLevels
{
public static void main(Args _args)
{
// TOP to BOTTOM hierarchy level data
void loopchild(RefRecId _recId)
{
EcoResCategory ecoResCategoryChk, ecoResCategoryChild;
while select ecoResCategoryChk
where ecoResCategoryChk.ParentCategory == _recId
{
//Child query insert to table Write ur logic
Info(ecoResCategoryChk.Name);
ecoResCategoryChild.clear();
select firstonly ecoResCategoryChild
where ecoResCategoryChild.ParentCategory == ecoResCategoryChk.RecId;
if(ecoResCategoryChild)
{
loopchild(ecoResCategoryChild.ParentCategory);
}
}
}
EcoResCategory ecoResCategory;
EcoResProductCategory ecoResProductCategory, ecoResProductCategoryCHk;
RefRecId parentCategory;
select firstonly ecoResCategory
where ecoResCategory.Name == "Refrigeration";
parentCategory = EcoResCategory.RecId;
if(parentCategory)
{
//Parent query insert - Write ur logic
Info(ecoResCategory.Name);
loopchild(parentCategory);
}
}
}