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 / Patching Gallery resul...
Power Apps
Answered

Patching Gallery results in duplicate items in SharePoint list

(0) ShareShare
ReportReport
Posted on by 5,836 Moderator

I have an app where I am patching a gallery to a SharePoint list.   The app is only creating new items (by default) and not used to udpate anything.   It was working correctly initially but now is creating duplicate items from the last item entered into the collection rather than creating a unique item for each item in the collection.

 

Input:

 

Input.jpg

 

 

Collection:

 

Collection.jpg

 

Patch Statement:

 

Patch.jpg

 

SharePoint list with newly created items:

 

SPList.jpg

 

I am not knowledgable enough to figure this out.    It doesn't make any sense.

 

Categories:
  • RezaDorrani Profile Picture
    12,145 on at

    Hi @JR-BejeweledOne 

     

    In Patch you are using Defaults() - which means it will only create new items

     

    If you need to update items - you will need to replace Defaults with the item reference

     

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-patch

     

    Regards,

    Reza Dorrani

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

  • JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    Thanks.   I did indicate in the post that I am only creating new items.   It's not designed to update any items.

  • RezaDorrani Profile Picture
    12,145 on at

    Hi @JR-BejeweledOne 

     

    ForAll(HolidayCollection2,Patch('Holiday List',Defaults('Holiday List', {Holiday: HolidayCollection2[@Holiday],Country: HolidayCollection2[@Country],  .... and so on

     

    Try this

     

    Regards,

    Reza Dorrani

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

  • JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    Not sure I follow.   

     

    How do I get .......{Holiday: HolidayCollection2[@Holiday],Country.......     out of (Holiday: tiHolidayDisplay.Text,Country.....)?

     

    Using  (Holiday: HolidayCollection2[@tiHolidayDisplay.text],.....    Just gives an error.

  • RezaDorrani Profile Picture
    12,145 on at

    Hi @JR-BejeweledOne 

     

    Use  as is -  {Holiday: HolidayCollection2[@Holiday]

     

    HolidayCollection2[@Holiday] - will get the Holiday column information from the HolidayCollection2 collection

     

    You dont need to refer to tiHolidayDisplay.text

    do not use - (Holiday: HolidayCollection2[@tiHolidayDisplay.text],.....    

  • JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    I think you may be confused.    I am not 'getting' anything from the SharePoint list.   The list is a repository only.

     

    This app is using information from other sources to populate the SharePoint list and that is all.   It's only function is to create new items in that list.   There is no information in the list for it to get.  

     

    All of the information being used in the PowerApp is from other data sources and then compiled into an internal collection within the app (created when the PowerApp is opened) and then patched into the SharePoint list.

     

    Also there is no Holiday column in the collection.  

     

     

     

  • Verified answer
    RezaDorrani Profile Picture
    12,145 on at

    Hi @JR-BejeweledOne 

     

    ForAll(HolidayCollection2,Patch('Holiday List',Defaults('Holiday List', {Holiday: HolidayCollection2[@Holiday],Country: HolidayCollection2[@Country] .....

     

    Did you try the above formula?

     

    I understand we are not reading but patching to SharePoint

    The above formula, just reads data from your collection HolidayCollection2 - and use the data within that collection to add information to SP list

     

     

     

     

     

     

  • JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    That seems to have partially worked, although I was unable to use it for the Date picker items.  I get an error when trying to set the date picker items that way.

     

    So the dates are still duplicated from the last item in the collection while the other fields are now correct and unique for each item.

  • RezaDorrani Profile Picture
    12,145 on at

    @JR-BejeweledOne 

     

    check data in the gallery HolidayCollection2

    you can go to View and see data in a collection

     

     

  • JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    It was the fact that the SharePoint list was looking for a Date/Time value and not a text value.   I changed the list fields to 'single line of text' and it works fine now.

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 381 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 340

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard