ECORESCATEGORY Table in Dynamics-SSC
Query to get the ecorescategory branches and nodes in ax 2012
this.parmQuery().dataSourceTable(tablenum(EcoResCategory),
1).clearRanges();
categoryBuildRange =
this.parmQuery().dataSourceTable(tablenum(EcoResCategory),
1).addRange(fieldnum(EcoResCategory, RecId));
categoryEnum =
category.getEnumerator();
while (categoryEnum.moveNext())
{
categoryRecid =
categoryEnum.current();
select ecoResCategory where
ecoResCategory.RecId == categoryRecid;
currentLevel =
ecoResCategory.Level;
lowestlevel =
ecoResCategory.getLowestLevel();
categoryHierarchy =
ecoResCategory.CategoryHierarchy;
while(currentLevel <=
lowestlevel)
{
while select ecoResCategoryChild
where ecoResCategoryChild.CategoryHierarchy == categoryHierarchy
&& ecoResCategoryChild.Level ==
currentLevel
{
categoryRecid =
ecoResCategoryChild.RecId;
while select * from ecoResCat
order by
ecoResCat.NestedSetLeft
where ecoResCat.CategoryHierarchy ==
ecoResCategoryChild.CategoryHierarchy
&&
ecoResCat.NestedSetLeft <=
ecoResCategoryChild.NestedSetLeft
&&
ecoResCat.NestedSetRight >= ecoResCategoryChild.NestedSetRight
{
if(ecoResCategory.RecId ==
ecoResCat.RecId)
{
select * from
ecoResCategoryisLeaf
order by
ecoResCategoryisLeaf.Name
where ecoResCategoryisLeaf.CategoryHierarchy ==
ecoResCategoryChild.CategoryHierarchy
&&
ecoResCategoryisLeaf.ParentCategory ==
ecoResCategoryChild.RecId
&&
ecoResCategoryisLeaf.IsActive == true;
if(!ecoResCategoryisLeaf)
{
allCategory.addEnd(categoryRecid);
}
break;
}
}
}
currentLevel++;
}
}
Item lookup of ecorescategory in ui builder class
private void
itemLookup(FormStringControl _control)
{
Query query;
QueryBuildDataSource
qbdscategory,qbdsProductCategory,qbdsInvent,qbdsEcoProduct;
container brandCon;
int counter;
RecId
brandCategoryRecid,categoryRecid,segmentRecid;
EcoResCategory category,segmentCategory;
;
query = new query();
qbdsInvent =
query.addDataSource(tableNum(InventTable));
qbdsEcoProduct =
qbdsInvent.addDataSource(tableNum(EcoResProduct));
qbdsEcoProduct.relations(false);
qbdsEcoProduct.addLink(fieldNum(EcoResProduct,RecId),fieldNum(InventTable,Product));
qbdsProductCategory =
qbdsEcoProduct.addDataSource(tableNum(EcoResProductCategory));
qbdsProductCategory.relations(false);
qbdsProductCategory.addLink(fieldNum(EcoResProduct,RecId),fieldNum(EcoResProductCategory,Product));
qbdscategory =
qbdsProductCategory.addDataSource(tableNum(EcoResCategory));
qbdscategory.relations(false);
qbdscategory.addLink(fieldNum(EcoResProductCategory,Category),fieldNum(EcoResCategory,RecId));
ECORESCATEGORY LOOKUP MULTISELECT
public void
categoryLookup()
{
Query query = new
Query(querystr(ProcCategoryEcoResCategory));
int mutiSelectTableNum =
tablenum(EcoResCategory);
container selectedFields =
[mutiSelectTableNum, fieldname2id(mutiSelectTableNum, fieldstr(EcoResCategory,
Name))];
SysLookupMultiSelectCtrl::constructWithQuery(this.dialog().dialogForm().formRun(),
categoryField.control(), query, false, selectedFields);
}