web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to make mandatory on item creation form ax 2012

(0) ShareShare
ReportReport
Posted on by 104

Hi Everyone,

67184.Capture.PNG

Could you please suggest how to make Retail category field mandatory in ax 2012?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Brandon Wiese Profile Picture
    17,790 on at

    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.

  • g.sathish Profile Picture
    104 on at

    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().

  • Verified answer
    Brandon Wiese Profile Picture
    17,790 on at

    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;
        }
  • g.sathish Profile Picture
    104 on at

    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.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 24

#2
Michel ROY Profile Picture

Michel ROY 14

#3
Jagadabi Profile Picture

Jagadabi 6

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans