Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Suggested answer

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

(1) ShareShare
ReportReport
Posted on by 196
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:
  • Suggested answer
    Michael E. Gernaey Profile Picture
    40,272 Super User 2025 Season 1 on at
    How to Prevent Duplicate records for the same date in the same month
    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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,522 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,890 Most Valuable Professional

Leaderboard