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 / Patch creates two reco...
Power Apps
Answered

Patch creates two records in SP list instead of one

(0) ShareShare
ReportReport
Posted on by 254

Hi, 
the following code will be executed when I press on a button. It simply copies the content of two inputfields into the Sharepoint List. 

It worked pretty well, until now it suddenly always duplicates the record. But I only want the the pair to be saved once into the Sharepoint List --> only one record is needed.. I hope someone can help with this or know what is my mistake:

If(
 IsEmpty(Filter(tblCutShelf; ShelfPlaces = txtShelfNo.Text));
 Patch(
 tblCutShelf;
 Defaults(tblCutShelf);
 {
 Titel: txtWarehouse2.Text;
 ShelfPlaces: txtShelfNo.Text
 }
 ))

 
Thank you very much in advance. 

Best.

Categories:
  • Prabhakar_S Profile Picture
    735 Moderator on at

    Hi @Applicable88 ,

     

    It seems like the code you've provided is designed to patch a record into the SharePoint list ('tblCutShelf') only if there isn't already a record with the specified 'ShelfPlaces' value. However, the issue might be related to how 'IsEmpty' is evaluating the condition.

     

    Here's a revised version of your code that explicitly checks for the presence of a record:

     

    If(
    CountRows(Filter(tblCutShelf, ShelfPlaces = txtShelfNo.Text)) = 0,
    Patch(
    tblCutShelf;
    Defaults(tblCutShelf);
    {
    Titel: txtWarehouse2.Text;
    ShelfPlaces: txtShelfNo.Text
    }
    )
    )

     

    This should help ensure that a record is created only if there isn't already one with the same 'ShelfPlaces' value. Adjustments might be needed based on the exact behavior you're looking for, but this should address the duplication issue.

     

    Thanks!!!

     

    Please consider marking my response as the accepted solution if it successfully resolves your concern. If you found the information beneficial in other aspects, kindly express your appreciation by giving it a thumbs-up.

  • Applicable88 Profile Picture
    254 on at

    Hi @Prabhakar_S ,
    thank you very much for your quick reply. It must be something else. As I said the strange thing is that it once work. 
    And now I cut down the code without even the "if-statement" like this and it still make two rows, even though I have only two inputfields that I want to patch:

     

     Patch(
     tblCutShelf;
     //Defaults(tblCutShelf);
     {
     Titel: txtWarehouse2.Text;
     ShelfPlaces: txtShelfNo.Text
     }
     )
     

     

    Even with this little snippet its still patch two rows instead of one. I'm not even make a duplicate search now, no filter function, just simple patch. 
    Hope someone can help me out here what is wrong. 

  • Applicable88 Profile Picture
    254 on at

    What I found is that the Patch function instead of doing one record, its doing still two records. 
    Its always the same pattern:

    Titel Shelfplaces
    1111 abcd
      abcd
    2222 dcba
      dcba


    Its always two rows, one with the content and one without Titel,but the shelfplaces. 
    Home someone can help me out here. 

  • Verified answer
    Applicable88 Profile Picture
    254 on at

    Problem solved, I accidentally add the same formular from OnSelect into Onchange of the inputfield. My intention was to enable the possiblity to submit the inputvalues with the "Enter" Button instead only via the regular button. 

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 382 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 329

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard