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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Integer field Restriction

(0) ShareShare
ReportReport
Posted on by 277

Hi,

how to restrict an integer field in form to allow only 4 characters?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    SAADULLAH M Z Profile Picture
    175 on at

    You have to write your logic in ValidateField method on that Table

    Here is the sample

    public boolean validateField(fieldId _fieldIdToCheck)
    {
       boolean ret;
    
       ret = super(_fieldIdToCheck);
    
       if (_fieldIdToCheck == fieldNum(TableName, IntegerField))
       {
           if (strlen(int2str(this.IntegerField)) > 4)
           {
               ret = checkFailed('only 4 characters or allowed');
           }
       }
    
       return ret;
    }
    

    DisplayLength Property still allow the user to enter any length of character. In form it will show only the defined display length.

    The above code will help you to validate the user entry.

  • Martin Dráb Profile Picture
    237,874 Most Valuable Professional on at

    It may need a bit better specification. For example, -123 has three figures, but four characters. What result would you like to get in this case?

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Ali Zaidi Profile Picture

Ali Zaidi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans