cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper III
Helper III

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
Highlighted
Resident Rockstar
Resident Rockstar

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
Highlighted
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.
Highlighted
Resident Rockstar
Resident Rockstar

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
Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (5,885)