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 365 | Integration, Dataverse...
Suggested answer

Assistance with Power Apps number validation

(1) ShareShare
ReportReport
Posted on by 2
Hi all, hoping I'm in the right forum for this. One of my roles within my organisation is leading some of the solution architecture for our MS Cloud for Healthcare dynamics solution. But it is a generalised Dynamics question. 
 
I'm trying to work out the code for how to validate a number (its actually Medicare number, 10 digits with some other rules that we can ignore for the time being). There is the standard OOTB number length limiter, but no minimum length etc. I was hoping a simple expression typed into the formula bar for the MaxLength property would work (see below). Otherwise I'd just place an icon so that a tick appears next to Medicare Number if it is not less than and not greater than 10 digits. 
 
The trouble is, I can't seem to find what I need online in forums etc. that allows me to enter an expression that actually doesn't error.
 
Can anyone advise an easy code script for this?
 
 
I have the same question (0)
  • Suggested answer
    Adrian Begovich Profile Picture
    1,027 Moderator on at
    Assistance with Power Apps number validation
    Hi,

    The Medicare Number field should be created as a whole number field with a minimum value of 0 and a maximum value of 999,999,999 in Dynamics 365. You can increase the minimum value to enforce a minimum length; e.g. a minimum Value of 10,000 will ensure that the Medicare Number field contains five digits.
     
    If the Medicare Number has been created as a text field instead of a whole number field, then you have the option of building on top of this Power Fx formula to create a solution, but I really recommend creating the Medicare Number field as a whole number field.
    With({nums: Sum(ForAll(Split(txtMedicareNumber.Text, ""), 
        If(IsNumeric(Result), 1, 0)), Value),
          chars: Sum(ForAll(Split(txtMedicareNumber.Text, ""), 
          If(!IsNumeric(Result), 1, 0)), Value)},
        If(nums >= 1 && chars <=10,
           "Valid",
           "Invalid"
        ) & " Format"
    )

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Sahan Hasitha Profile Picture

Sahan Hasitha 109

#1
Sahan Hasitha Profile Picture

Sahan Hasitha 109

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 77 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans