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?
15 REPLIES 15
Anonymous
Not applicable

@Bochie most of the solutions offered above should work for you. The reason they may not is possibly because you have TextInput fields inside your gallery that aren't tied to your data source. This could explain the erratic behaviour ie sometimes your Patch() works sometimes it doesn't. 

 

I just carried out a test on my side using:

UpdateIf(myList, 
  ID = Gallery1.Selected.ID, 
  {myColumn: TextInput1.Text})

and

Patch(myList, 
  LookUp(myList,ID = Gallery1.Selected.ID), 
  {myColumn: TextInput1.Text})

 ... and both worked for me. The key here is that Default property of the TextInput field is set to ThisItem.myColumn. Is your gallery setup like this?

 

A screenshot of your app and some example code would really help us solve this for you.

 

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!

Anonymous
Not applicable

@Bochie 

It's a good idea to mark a solution here, even if you think your last post is the solution ... which I think it is 🙂 

This will help others find an answer if they have a similar issue.

 

I'd completely forgotten about the 'Patch() a BLANK' issue, I have struck this before as well and found a solution. Well done for solving this!

Thank you @Anonymous !!!

Anonymous
Not applicable

Hello guys,

I'm wondering if you can help. The problem I have is the patch below is not running when I select my button with this in the OnSelect property. Only error is delegation warning which I am not worried about as not likely to be more than 3 items in the list at a time. Can anyone spot why this wont run? 

Thanks
Maiti

 

If(
CountIf(
lst_TrialsWeaving,
vartrialnum in Title
) < 1,
Patch(
lst_TrialsWeaving,
Defaults(lst_TrialsWeaving),
{
Title: vartrialnum,
'Loom Number': txt_Loom.Text,
'beam location': txt_beamloc.Text,
'beam batch number': txt_beambatch.Text,
'Beam details required': tgl_beamdetails.Value,
'Loomstate sample details': txt_sampledetails1.Text,
'Loomstate sample required': chk_samplesrequired1.Value,
'Loomstate testing required': chk_waitloomstate.Value,
'Weaving PI comments': txt_technicalcomments1.Text,
'Weaving technical supervision ': chk_technicalsupervision1.Text,
'Weaving input complete': tgl_inputcomplete.Value
}
),
UpdateIf(
lst_TrialsWeaving,
vartrialnum in Title,
{
'Loom Number': txt_Loom.Text,
'beam location': txt_beamloc.Text,
'beam batch number': txt_beambatch.Text,
'Beam details required': tgl_beamdetails.Value,
'Loomstate sample details': txt_sampledetails1.Text,
'Loomstate sample required': chk_samplesrequired1.Value,
'Loomstate testing required': chk_waitloomstate.Value,
'Weaving PI comments': txt_technicalcomments1.Text,
'Weaving technical supervision ': chk_technicalsupervision1.Text,
'Weaving input complete': tgl_inputcomplete.Value
}
)
);

Navigate(sc_sucesstechnical);

Anonymous
Not applicable

@Anonymous 

Please post this as a new forum question, this question has been solved. Doing this will also give you a better chance of more people seeing this and helping you out 🙂 

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.

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 (3,053)