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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Limit maximum length of quantity

(0) ShareShare
ReportReport
Posted on by 125

Hi experts,

some body tell me how to restrict Qty field till 9999 in the override method of field.The Qty field is coming in a forms grid.and its EDT is SalesOrderedQty. I dont want to handle it through EDT because it would disturb already entered values.Currently maximum range is in attached screen shot,it is accepting 15 digits before decimal point,i want just 4 digits before decimal point.

85441.Capture.PNG

*This post is locked for comments

I have the same question (0)
  • Faran Baig Profile Picture
    125 on at
    RE: Limit maximum length of quantity

    Thanks Nikolaos,i got my problem solved.

  • Faran Baig Profile Picture
    125 on at
    RE: Limit maximum length of quantity

    Yes,currently i want it to validate it in form.

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Limit maximum length of quantity

    But are you sure you want to validate it on the form instead of in the table. Now anyone who inserts data from other place than this form (Excel, data integrations, other form, x++ code) can insert values that are larger than 9999.

  • Verified answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Limit maximum length of quantity

    In your form, expand Data sources - your data source - your field. In Methods, right click - Override method - validate.

    Add your logic in the validate method and return true or false depending on the data in the field.

    public boolean validate()
    {
        boolean ret = true;
        if (myTable.myField > 9999)
        {
            ret = checkFailed("Max value is 9999.");
        }
        return ret;
    }


  • Faran Baig Profile Picture
    125 on at
    RE: Limit maximum length of quantity

    Hi Nikolaos,

    but how to set it in code?What will be the syntax?

  • Faran Baig Profile Picture
    125 on at
    RE: Limit maximum length of quantity

    No Crispin,

    I have my custom form and in data source a custom table,i dont know how set it in code,what will be the code,i want it on form,may be code should be written in field method or form data source mehtod.Please Guide me.

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Limit maximum length of quantity

    You can use event handler or Chain of Command in the validateField and/or validateWrite method of the underlying table (or form data source, depending on your requirement).

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 2

#1
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

#1
Guy Terry Profile Picture

Guy Terry 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans