cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Bochie
Resolver I
Resolver I

Help with Patch

Hi All!

I am trying to patch into just one item in a SharePoint list with over 600 items. Sometimes, the patch with come through. Sometimes it won't. I am not getting a delegation warning and I also placed the save/patch icon within the gallery itself. How can I make this consistently save/patch? The patch formula I am using is below. 

 

Patch(
mySharePointList,
mySharePointListGallery.Selected,
{
Week1: Value(tmWk1.Text),
Week2: Value(tmWk2.Text),
Week3: Value(tmWk3.Text),
Week4: Value(tmWk4.Text),
Notes: tmNotes.Text
}
)

I've also tried to use a variable like Set(varTargetRecord, mySharePointListGallery.Selected) on select of the icon then using the variable to patch. I still get inconsistent results. Sometimes it would save, sometimes it won't. Am I missing something?
1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Anonymous,

Indeed, all of the formula's you suggested were working. I now found what was wrong. It turns out all the fields/columns (Week1, Week3, Week3, Week4) needed to have an initial value. That was the pattern I noticed. So for the other items, they all had blanks for those fields while the others had zeros. So the quick fix was to put a zero at the fields and had it default to zero. My users edit it and enter a digit from 1-100 so it's all good. I just didn't know it had to have an initial value for the patch to work 🤦🏽‍♂️

Thank you so much for all your suggestions/replies @Anonymous , @RandyB , @classicman!

View solution in original post

15 REPLIES 15
Anonymous
Not applicable

@Bochie 

Try using this:

 

Patch(
   mySharePointList,
   ID = mySharePointListGallery.Selected.ID,
   {
     Week1: Value(tmWk1.Text),
     Week2: Value(tmWk2.Text),
     Week3: Value(tmWk3.Text),
     Week4: Value(tmWk4.Text),
     Notes: tmNotes.Text
   }
)

Thank you @Anonymous for your reply but I get a "The function 'Patch' has some invalid arguments" when I tried it.

RandyHayes
Super User
Super User

@Bochie 

I believe what @Anonymous was going for was the UpdateIf function:

UpdateIf(
   mySharePointList,
   ID = mySharePointListGallery.Selected.ID,
   {
     Week1: Value(tmWk1.Text),
     Week2: Value(tmWk2.Text),
     Week3: Value(tmWk3.Text),
     Week4: Value(tmWk4.Text),
     Notes: tmNotes.Text
   }
)

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Anonymous
Not applicable

@RandyHayes That was going to be my next suggestion - shoulda gone there first lol

RandyHayes
Super User
Super User

@Anonymous 

Yep - as I read the post I was thinking to do an UpdateIf - then saw your replay and noticed the mistype.

 

@Bochie  Give @Anonymous 's suggestion a try (with the change to UpdateIf) and see if that hits the nail on the head for you.

If not, the other things to consider are potential conversion issues with the Value functions.  Is there a possibility that one of them is failing...which can cause the entire patch to fail.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Hi @RandyHayes and @Anonymous ,
I tried the UpdateIf function and it resulted to updating all the columns/fields being updated even if I ONLY updated a single column (for example only tmWk1 field was updated). I still can't figure out though why Patch wouldn't work for some? Could it be a delegation issue? It doesn't give me a squiggly line so I didn't consider that before. Thanks much for your responses!

classicman
Regular Visitor

Where is your patch being stored? Not sure what your design for this looks like, but I typically gravitate to using ThisItem. Might be more effective to assign the Patch function to the field you're updating so that you're only updating what you intend to.

 

Patch(
   mySharePointList,
   ThisItem,
   {
     Week1: Value(tmWk1.Text),
     Week2: Value(tmWk2.Text),
     Week3: Value(tmWk3.Text),
     Week4: Value(tmWk4.Text),
     Notes: tmNotes.Text
   }
)

 

Hi @classicman , if your question was which control triggers the Onselect event, it's an icon inside the gallery itself. I was using mySharePointListGallery.Selected and changed that to your suggestion with "ThisItem" for the patch. It's still behaving the same: it would work in some of the records, but won't work on the others. That really is what I cannot figure out. When I use the UpdateIf function, all the fields are set to "0" zero after the update, nothing from the Text Input control is passed. Thanks for your response!

Hmm...How about this:

 

Patch(
   mySharePointList,
   First(Filter(mySharePointList, ID = mySharePointList.Selected.ID)),
   {
     Week1: Value(tmWk1.Text),
     Week2: Value(tmWk2.Text),
     Week3: Value(tmWk3.Text),
     Week4: Value(tmWk4.Text),
     Notes: tmNotes.Text
   }
)

 

 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (6,247)