cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
DS2
Advocate III
Advocate III

How to check that a field value is unique before saving back to a SharePoint list?

I have an Input Screen with a Form where there is a text input field for an invoice number. I have a Save Icon that upon OnSelect Submits the Form and the data is saved to a SharePoint List. We need all invoice numbers to be unique to avoid duplicate entries. Although I can make the Invoice number column in SharePoint unique, there is no error message in PowerApps (or a useful one anyway) although a record with a duplicate invoice number cannot be saved. 

 

How can I check for a duplicate entry upon Submit? I already have some code in OnSelect for the Save icon:
SubmitForm(Form1);
Set(
selectedInvoice,
Blank()
);
ResetForm(Form1);
NewForm(Form1)SubmitForm.jpg

10 REPLIES 10

@sajarac 

Try changing your formula to this:

If(
   IsBlank(Trim(DataCardValue5.Text)), 
      "A Country Code is required",   
   CountRows(Filter(Country, CoO_Code = Value(Trim(DataCardValue5.Text)) ) > 0, 
      "Duplicate Code not allowed",
   ""
)

Note the use of the Value Function

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,397)