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 / Question - Patch - Is ...
Power Apps
Answered

Question - Patch - Is it possible to patch a record variable or context?

(0) ShareShare
ReportReport
Posted on by 98

Hi,

 

I have a simple app divded into 2 screens. One screen is a gallery with many items. Onclick, I transfert ThisItem over tot he next screen. So far everything is working flawless. 

 

Now the problem I have is that at somepoint, I need to be able to patch ThisItem when inputs or dropdowns are changed. This allows me to keep my background data and interface in sync so that on save I can easily grab ThisItem and update my Sharepoint list. 

 

However, Patch does not seem to work on variables or Context (Set() or UpdateContext()). So mmy solution was to create a collection and on the default of the input I do something like First(Collection). In thoery this would work but seems clunky and messy.

I could also do UpdateContext directly but since it comes from Sharepoint, it adds a bunch of hidden columns that becomes impossible to work with in a clean fashion. 


Im wondering if anyone knows of a better way to update a Context via Patch() somehow? 

Categories:
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    This may not completely address your situation, but it sparked my response because I do see this often...

    What gets missed sometimes is that Patch actually *returns* the results. (think about that for a moment).

     

    Example: let's say you store ThisItem in a variable - Set(myItem, ThisItem)

     

    So, doing a:

       Patch(myItem, {someField:someValue})

    will do very little for you.  What you really want is:

       Set(myItem, Patch(myItem{someField:someValue}))

    This will update the variable myItem with the changes you want.

     

    Of course, this is ONLY for the local variable/copy of that information.  If you want to push that back to the data source, you will eventually need to do a Patch(dataSource, recordToChange, myItem)

     

    Hope this gives you some help.

  • Verified answer
    KroonOfficeSol Profile Picture
    587 on at

    @RandyHayes really nice approach I must say

     

    @Owizardo

    Another solution is not to use a variable but a collection to store your ThisItem, so like

    ClearCollect(_ThisItemTemp, ThisItem)

    You can easily patch this collection and right it back to the SharePoint I would think.

     

    Hope this helps to,

     

    Paul

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

#2
Mohsin Ali Profile Picture

Mohsin Ali 368

#3
WarrenBelz Profile Picture

WarrenBelz 244 Most Valuable Professional

Last 30 days Overall leaderboard