Hi,
Im trying to update some product categories by a script. But im having truble getting it correct.
I belive the issue is when i trying to find the recid of category by using the Code.
Some imput whould be much apriciated!
static void UpdateProductCategoryHierarchy(Args _args)
{
EcoResProduct _EcoResProduct;
EcoResProductCategory _EcoResProductCategory;
EcoResCategoryHierarchy _EcoResCategoryHierarchy;
EcoResCategory _EcoResCategory;
changecompany("12")
{
select forUpdate _EcoResProduct
where _EcoResProduct.DisplayProductNumber == "XXX"; // Item Number
select forUpdate _EcoResProductCategory
where _EcoResProductCategory.Product == EcoResProduct::findByDisplayProductNumber(_EcoResProduct.DisplayProductNumber).RecId;
if (_EcoResProductCategory)
{
ttsBegin;
_EcoResProductCategory.Product = EcoResProduct::findByDisplayProductNumber(_EcoResProduct.DisplayProductNumber).RecId;
EcoResCategoryHierarchy = EcoResCategoryHierarchy::findByName("QQQ"); // Hiearchy name
_EcoResProductCategory.CategoryHierarchy = EcoResCategoryHierarchy.RecId;
_EcoResProductCategory.Category = _EcoResCategory::find('YYY', _EcoResCategory.Code).RecId; // Trying to find the recid of category by using the Code.
_EcoResProductCategory.update();
ttsCommit;
}
}
}
*This post is locked for comments