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 / How to Prevent Duplica...
Power Apps
Suggested Answer

How to Prevent Duplicate records for the same date in the same month

(1) ShareShare
ReportReport
Posted on by 202
Hi All
 
I have an app that captures records on the last day of the month through out the year but I don't want the app to capture the same record twice in the same month .
 
The app has a gallery and edit form Iam using a SQL DataSource 
 
 
below is the save formula on the Form 
 
SubmitForm('Waste_ Form');If('Waste_ Form'.ErrorKind=ErrorKind.None,Navigate(GALWaste_Capture1,ScreenTransition.None));
 
 
This is also my gallery formula
 
SubmitForm('Waste_ Form');If('Waste_ Form'.ErrorKind=ErrorKind.None,Navigate(GALWaste_Capture1,ScreenTransition.None));
 
1. How do I prevent it from capturing the same record twice based on the Capture Date Field?
If('Waste_ Form'.Mode=FormMode.Edit,Parent.Default,Today())
 
2.How to I also show a pop up that once the same date is used it shows that you cannot capture the same date in the same month?
 
The Videos Iam seeing are based on SharePoint Lists which is a bit confusing.
 
 
 
 
 
Categories:
I have the same question (0)
  • Suggested answer
    Michael E. Gernaey Profile Picture
    53,978 Moderator on at
    Ok
     
    It's pretty clear what has to happen at least based on your picture and I also recommend a change to what you have
     
    Let's say you have a DataSource called ME
    And it has 5 Columns
    4 are text and 1 is Date
     
    What I suggest you do is the following
     
    First Suggestion, move all code AfTER the submit to the OnSuccess property of the form.
     
    Now to your ask.
     
    We need to verify that there is NO record before letting them submit
     
    1. In your Buttons DisplayMode property we want to check if there is an existing record. If there is then we want to make the button disabled, if not then edit
     
    If(IsBlank(LookUp(MyDatasource, fIeld1 = FormDataControl.Text, field2 = FormDataControl.Text, field3 = DateValue), DisplayMode.Enabled, DisplayMode.Disabled)
     
    What this does, is a lookup against your SQL Source, using the FIelds in the table in SQL, and the values FROM the Form.
     
    If it returns IsBlank, that means it doesn't exist, and we want people to be able to Submit.
    if it returns a Row, then we know it would be a duplicate and keep the button from being clicked.
     
    You could also have a Label somewhere on the screen. Make the text something like "This would create a duplicate, please review your data"
    Then in the text labels Visible property you would put the a similar expression as in the Buttons DisplayMode
    The difference is the Visible property is a boolean, so you only need to check if the returned row IsBlank = true, so the label shows up.
     
    IsBlank(LookUp(MyDatasource, fIeld1 = FormDataControl.Text, field2 = FormDataControl.Text, field3 = DateValue)
     
     
     
    This is how you check for duplicates, block them from submitting AND give them a warning in a label so they know why they cannot submit.
     
     
     
     
     
     
     
     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 1,055

#2
Valantis Profile Picture

Valantis 666

#2
11manish Profile Picture

11manish 666

Last 30 days Overall leaderboard