web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Checking for duplicate...
Power Apps
Answered

Checking for duplicate record in Patching Table before Patching

(1) ShareShare
ReportReport
Posted on by 107
Modern Controls off,
 
I have an App where one of my screens the Form is sourced and writing into 1 table and the Onsuccess Property of the form contains a Patch to create child records into a 2nd table based on Selections of check boxs in a gallery outside the form container. 
 
The only hitch is i can technically duplicate the child records by spaming the edit and submit button in the 2nd table (nothing happens with the first table data it does what its supposed to) 
 
essentially i would like the patch to check for if Field ECI_ID and Field DieNumber exists then to not create a new child record
 
in the table i am patching too Duplicates of the ECI_ID shall be allowed but the combination of ECI_ID to Die NUm Should NOT be allowed to duplicate. 
 
heres the current patch in OnSuccess property of the form
 
 ForAll(Filter(Gallery1.AllItems, Checkbox2_1.Value = true),
 Patch(ECI_Dies, Defaults(ECI_Dies),
  {
    DieNum:ThisRecord.Checkbox2_1.Text,
    ECI_ID:SelectedRecordTitle1_1.Text,Product:DataCardValue9.SelectedText.Value,Content:DataCardValue4_1.Text,ECI_Level:DataCardValue3_1.Text,Trial:DataCardValue2.Selected.Value,Cavity:DataCardValue1_1.Selected.Value
 
  }
  )
 )
  ;UpdateContext({ CurrentItem: Self.LastSubmit, editMode: false, newMode: false })
 
 
What code would I want to use to check for this type of duplication?
Categories:
I have the same question (0)
  • Suggested answer
    Daniel Bocklandt Profile Picture
    5,117 Super User 2025 Season 2 on at
    Hey, 
     
    could you try this: 
    ForAll(
        Filter(
            Gallery1.AllItems, 
            Checkbox2_1.Value = true
        ),
        If(
            CountRows(
                Filter(
                    ECI_Dies,
                    DieNum=ThisRecord.Checkbox2_1.Text,
                    ECI_ID=SelectedRecordTitle1_1.Text
                )
            )<1,
            Patch(
                ECI_Dies, Defaults(ECI_Dies),
                {
                DieNum:ThisRecord.Checkbox2_1.Text,
                ECI_ID:SelectedRecordTitle1_1.Text,
                Product:DataCardValue9.SelectedText.Value,
                Content:DataCardValue4_1.Text,
                ECI_Level:DataCardValue3_1.Text,
                Trial:DataCardValue2.Selected.Value,
                Cavity:DataCardValue1_1.Selected.Value
                }
            )
        )
     );
    UpdateContext(
        {
        CurrentItem: Self.LastSubmit, 
        editMode: false, 
        newMode: false 
        }
    )
    Let me know if this helped you. If it did, please accept this as soluiton so others can find it as well. 
     
  • CP-23071818-0 Profile Picture
    107 on at
    Okay I updated the code in the Onsuccess and i get the following warning:
    "Incompatible type for comparison, These types cant be compared, Text,Error"
     
    Then inside the instruction window it is red highlighting 
     
    Mousing over the red underline it says Name isnt valid 'Checkbox2_1' isnt recognized ?


    Update: i changed Checkbox2_1.text to [@Checkbox2_1].text and it recognized it and functioned correctly
  • CP-23071818-0 Profile Picture
    107 on at
    let it be known that DBO_DVs answer worked as a solution. the "Does this answer your question?" check box is not functioning on my end (Edge)

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard