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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Validation on string field to only allow Integer or Real (Numeric) values

(0) ShareShare
ReportReport
Posted on by 55

Ok so I have a custom form and a custom table, in it I have a Qty field, which is a String field. I want to implement validation on it to only allow numeric values.

I tried the isInteger() method, but during testing, I came across the fact that it allowed values like 100, 50, 44, but when I tried a decimal value like 5.5, it gave me the error I threw in my code of Please enter numeric value.

Kindly help on how to implement this. I am working on overriding the validateWrite method.

(Also, I know I can just use a real field instead, but this is an old customization and I have to work with this string field as it is being used in other places.)

Categories:
I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    240,191 Most Valuable Professional on at

    I still recommend fixing the bug in the design. Using a string data type means that you won't be able to correctly sort and filter by quantity, you won't be able to use it in aggregations, it won't be formatted correctly… You may end up doing more and more workarounds that will take more time than fixing the data model. Also, performance will suffer if you need to run queries against the quantity and you'll have to do it in inefficient ways.

     

    If you want to stick to the validation only, I suggest you check the previous discussion in Validation for numeric values in AX. As I mentioned there, how you need to implement it depends on what exactly you want to do. Remember that users may use various number formats (for example, users in some countries use a decimal points, others use a decimal comma). I guess you'll decide to enforce a particular format, regardless of the format used for actual numeric fields, but it's your decision.

     

    By the way, is the about F&O or AX? You've selected both categories.

  • SA-15031413-0 Profile Picture
    55 on at

    Thank you for your response, I followed the Regex implementation and it worked.

    This post was concerning F&O, thanks.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 382 Super User 2026 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 265 Most Valuable Professional

#3
Subra Profile Picture

Subra 262

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans