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 :
Power Platform Community / Forums / Power Apps / Show error message whe...
Power Apps
Answered

Show error message when entering duplicate value in number field

(0) ShareShare
ReportReport
Posted on by 16

Hello,

 

I have a simple number field with enforce unique values selected.

 

If I add a duplicate value there is no warning at all, it simply doesn't save. The default errormessage for the datacard doesnt show up at all.

 

What is the simplest way to give an error message or flag a duplicate value in a number column? thanks!

 

Categories:
I have the same question (0)
  • Verified answer
    Ami K Profile Picture
    15,687 Super User 2024 Season 1 on at

    Hi @jdellipa - to display an error message, you could try the following pattern:

     

     

     

     

    If(
     IsError(
     Patch(
     'YOUR_DATA',
     Defaults('YOUR_DATA'),
     YOUR_FORM_NAME.Updates
     )
     ),
     // On failure
     Notify(
     If(//check for duplicates
     !IsBlank(
     LookUp(
     'YOUR_DATA',
     YOUR_NUMBER_COLUMN = YOUR_DATA_CARD_VALUE
     )
     ),
     "Duplicate",		//if there is a duplicate, show this message
     "Some other Error" 	//if there is not a duplicate but there is a different error, show this message
     ),
     NotificationType.Error
     ),
     // On success
     Notify(
     "Saved",
     NotificationType.Success
     )
    )

     

     

     

    Alternatively, you could separate out the duplicate check and leverage it for anything else. For example you could wrap the below formula around an IF condition to display a specific message, or you could apply the formula to the DisplayMode property to the save button and set it to disabled if the formula returns true.

     

     

     !IsBlank(
     LookUp(
     'YOUR_DATA',
     YOUR_NUMBER_COLUMN = YOUR_DATACARD_VALUE
     )
     )
     //true if there is a duplicate
     //false if there is not a duplicate

     

  • v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi @jdellipa,

    Do you want to force unique numbers input in the TextInput control?

     

    To force unique number from 0-9, you could try Regx as below:

    IsMatch(TextInput12.Text,"^(?!\d*?(\d)\d*?\1)\d{1,10}$")
    

    vqiaqimsft_0-1681178992066.png

    To apply to your error message, just set the Text property as below:

    If(!IsMatch(TextInput12.Text,"^(?!\d*?(\d)\d*?\1)\d{1,10}$"),"Only unique numbers allowed!")

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!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 352 Most Valuable Professional

#2
11manish Profile Picture

11manish 192

#3
Valantis Profile Picture

Valantis 128

Last 30 days Overall leaderboard