Announcements
No record found.
Hi Everyone,
Could you please suggest how to make Retail category field mandatory in ax 2012?
*This post is locked for comments
The name of that form is EcoResProductCreate.
That Retail category field is not bound directly to a database field, but is instead a standalone control.
Probably the easiest way to make it mandatory is add the following line to the element.setCategoryDropdownVisible() method.
private void setCategoryDropdownVisible() { if (isConfigurationkeyEnabled(configurationKeyNum(Retail)) && EcoResCategoryHierarchyRole::existRole(EcoResCategoryNamedHierarchyRole::Retail)) { categoryReferenceGroup.enabled(true); categoryReferenceGroup.visible(true); categoryReferenceGroup.mandatory(true); // add this line } else { categoryReferenceGroup.enabled(false); categoryReferenceGroup.visible(false); } }
Sometimes all this manages to do it put a red line under the field but does not enforce it. If that happens, add some code to the element.validateWrite() method to check if the field is empty.
Now i can see red line under the field. But its simply allowing with empty field.
I am not technically strong. If you dont mind, please suggest what needs to be written in element.validateWrite().
I don't have Retail turn on in my current environment, so this is just a guess. I've added code at lines 17 thru 20 in the snippet below.
public boolean validateWrite() { boolean ret = true; if (companyIdInit != curext()) { ret = checkFailed(strFmt("@SYS4002764", tableStr(EcoResProduct))); } ret = identification_ProductNumber.validate() && ret; if (releaseProductToCompany) { ret = itemIdentification_ItemId.validate() && ret; } if (!EcoResCategory.RecId) // add these lines { ret = checkFailed(strFmt("Retail category must be specified")); } ret = ret && ecoResProduct.validateWrite(); if (ecoResProduct.isProductMaster()) { ret = productDimensionGroup.validate() && EcoResProductDimensionGroupProduct::checkDimensionGroupValidForProduct( ecoResProduct, productDimensionGroup.value()) && ret; }
Thanks Brandon Wiese. Its working perfectly.
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
Congratulations to our 2026 Super Stars!
We are thrilled to have these Champions in our Community!
These are the community rock stars!
Stay up to date on forum activity by subscribing.
CP04-islander 24
Michel ROY 14
Jagadabi 6