cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Owizardo
Level: Powered On

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

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? 

1 ACCEPTED SOLUTION

Accepted Solutions
KroonOfficeSol
Level 10

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

@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

View solution in original post

2 REPLIES 2
Super User
Super User

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

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.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
KroonOfficeSol
Level 10

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

@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

View solution in original post

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (5,900)