Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Unanswered

Patch Collection

(0) ShareShare
ReportReport
Posted on by

i have collection(selected records from Gallery) in powerapps which contains 20 coloumn, now i want to patch few coloumns from collection to Sharepoint list. how to patch the code?

Categories:
  • venky232 Profile Picture
    on at
    Re: Patch Collection

    its working now, thanks for Support

  • madlad Profile Picture
    2,637 Super User 2025 Season 1 on at
    Re: Patch Collection

    If I understand correctly, your records are only being compared against the user's first record when patching?

    I think the problem lies in the:

    Filter(
     MyCollection,
     Not(ThisRecord.'Title' in LookUp('ABC', 'Created By'.Email = User().Email, Title))
    )

    LookUp only returns the first value it finds, so it will only compare your values to the first one created by the user. Try switching the code snippet above to something like:

    Filter(
     MyCollection,
     Not(ThisRecord.'Title' in Filter('ABC', 'Created By'.Email = User().Email).Title)
    )

    Please note I haven't tested this code so you may have to play around with it a little bit. 

  • venky232 Profile Picture
    on at
    Re: Patch Collection

    again got some issue, here it checking duplicate record only 1st item, if i going to patching mutiple records.

    RemoveIf(MyCollection, IsBlank('Title'))

    If(!IsEmpty(MyCollection),
    ForAll(
    Filter(
    MyCollection,
    Not(ThisRecord.'Title' in LookUp('ABC', 'Created By'.Email = User().Email, Title))
    ),
    Patch('ABC', Defaults('ABC'), { Title: ThisRecord.'Title' })
    )
    )

  • madlad Profile Picture
    2,637 Super User 2025 Season 1 on at
    Re: Patch Collection

    that makes sense, as it's likely still selected- if the collection is only being used to patch to the SharePoint list, you could clear it after the patch statement runs, which should solve this.

     

    If you can't clear the collection quite yet, but  you never want to have duplicate records in the list, you could also include something like:

     

    If(
     !(ThisRecord.Title in 'ABC'.Title), 
     Patch(...)
    ) 

     

    in your ForAll, just to ensure duplicates don't patch.

  • venky232 Profile Picture
    on at
    Re: Patch Collection

    its working ,thanks for your Support. 
    one question, when user click submit button twice ,same selected records patching twice in list

  • madlad Profile Picture
    2,637 Super User 2025 Season 1 on at
    Re: Patch Collection

    Try:

    If(
     !IsEmpty(MyCollection),
     ForAll(
     MyCollection,
     Patch(
     'ABC',
     Defaults('ABC'),
     {
     Title: ThisRecord.'Title'
     }
     )
     )
    )

    Please also confirm that you have no records with a blank title in the collection-

    This could be accomplished using something like, just prior to your Patch statement:

    RemoveIf(
     MyCollection,
     IsBlank(Title)
    )

     

  • venky232 Profile Picture
    on at
    Re: Patch Collection
    ForAll(
        MyCollection,
        If(
            !IsEmpty(MyCollection),
            Patch(
                'ABC',
                Defaults('ABC'),
                {
                    Title: ThisRecord.'Title'
                })))

    still showing empty record in SP list
         
  • madlad Profile Picture
    2,637 Super User 2025 Season 1 on at
    Re: Patch Collection

    Try something like:

    If(
     !IsEmpty(*YourCollection*),
     Patch(...)
    )
  • venky232 Profile Picture
    on at
    Re: Patch Collection

    its working but if collection is empty and when user click submit button , it is creating empty record in SP list. how to avoid this?

  • madlad Profile Picture
    2,637 Super User 2025 Season 1 on at
    Re: Patch Collection

    I'm assuming your SharePoint list and collection are set up similarly. To patch items from a collection as new items, you could try something along the lines of

    ForAll(
     *YourCollection*,
     Patch(
     *YourSPList*,
     Defaults(*YourSPList*),
     {
     Value1: ThisRecord.Value1,
     Value2: ThisRecord.Value2,
     Ect.
     }
     )
    )

     To update records instead of creating new ones, specify the record to update instead of using Defaults(YourSPList) in your patch statement. 

     

    For more info on Patch, see The Documentation

     

    Hope this helps!

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,524 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,906 Most Valuable Professional

Leaderboard