Hi Community User,
The issue is not with your throw error, as you are throwing an error after you sum all the errors.
The issue is with the for loop -- you need to loop for records in the selected grid
public container productCatErrorMessage; /// this is the container for the checkGroup method
public void closeOk()
{
FormRun callerForm = this.args().caller();
EcoResProduct selectedProduct;
EcoResProductCategory tmpEcoResProductCategory;
EcoResProductCategory existingEcoResProductCategory;
container productErrorMessages;
if (callerForm && this.args().Caller().name() == formStr(EcoResCategory))
{
EcoResProductCategory tmpEcoResProductCategory;
tmpEcoResProductCategory.setTmp();
tmpEcoResProductCategory.setTmpData(tmpEcoResProductCategorySelected);
while select * from tmpEcoResProductCategory
{
productErrorMessages += this.checkGroup(tmpEcoResProductCategory);
}
if(productErrorMessages != conNull())
{
throw error (strfmt("@SYS82282", productErrorMessages));
}
}
next closeOk();
}
now in checkGroup method, you can get EcoResCategory or EcoResProduct from tmpEcoResProductCategorySelected like this:
EcoResCategory ecoResCategorySelected = EcoResCategory::find(tmpEcoResProductCategorySelected.Category)
EcoResProduct ecoResProductSelected = EcoResProduct::find(tmpEcoResProductCategorySelected.Product)
The other issue is it seems your checkGroup method returns container, make sure that the definition of this container is global not inside the check group method. As i showed you, above the closeOk, so that you make sure all errors appear. if it was inside, it means the container in this method will reset each loop resulting in one message only
let us know if it works
Thanks,
Layan Jweihan
Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future