i m looking for a fontion to verify if a product is exist in the procurement category hierarchy
If a procurement category is attached to the product, there is no error. else If no procurement category is attached to the product category, must display an error message by adding the category field anomalies messages.
i have add the code In this class **EcoResProductValidatonService ,it** is called by the button validate in th This listepage Product Information Management → Common → Products → Released Product
EcoResProductCategory resProductCateg;
if (TableParm::find().ProcRescatgProduct){
InventTable = InventTable::find( 'Item id' );
resProductCateg = EcoResProductCategory::findByProductIdCategoryHierarchyRole(inventTable.Product,EcoResCategoryNamedHierarchyRole::Procurement);
if(resProductCateg){
info(strFmt(" %1 procurement category is attached to this product ",InventTable.ItemId));
}else{
info(strFmt(" %1 No procurement category is attached to this product ",InventTable.ItemId));
}
}
But when i test it , the variable resproductCat has always 0 like value when i user debuger , knowing that i have some product in procurement category as shown in the following screen