Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Using Patch and LookUp to udpate a Sharepoint list

(1) ShareShare
ReportReport
Posted on by 84
I have a Gallery 01, and filter this Gallery 01 I collect in another Gallery 02 some record from the Sharepoint list “SpeseV01”.
In this way I create with the selected record in the Galley a collection “MyCollection”.
I modify the value of some records in the collection, and after I want update the record in the sharepoint list.
To make this, I have two buttons ( I’m not able use only one button, and I don’t’know why).
The first button  in the “OnSelect property” has:
 “ClearCollect(MyCollection; Gallery3.AllItems)”
So in this way I have all the elements modified in the collection.
The second button in the OnSelect property has :
“ForAll(

   MyCollection;
   Patch(
       SpeseV01;
       LookUp(SpeseV01; ID = ThisRecord.ID);
       {  Title: txtTitolo.Value;
           TipoSpesa: dropTipoSpesa.Selected;
           Importo: numImporto.Value;
           DataSpesa: dateDataSpesa.SelectedDate;
           Pagamento: dropPagamento.Selected;
           Fornitore: txtFornitore.Value;
           Note: txtNote.Value;
           DataRimborso: dateDataRimborso.SelectedDate;
           IDRimborso: txtIDRimborso.Value
           })
              )

But it doesn’t’ work.
If I use the monitor, the error is :
“Fetching Items failed. Possible invalid string in filter query.”
What can I do ? I’m new of patch and LookUp function.
Categories:
  • ancorte Profile Picture
    ancorte 84 on at
    Using Patch and LookUp to udpate a Sharepoint list
    The actual problem is the Patch..For All (i'm not sure to have understood exactly how it works).
     
    In the Gallery i have only the record that i filtered with another Gallery (and it's ok.)
    For example, if i have 3 records, an modify the value in the field "Import",  when i push the button it modify with the new value of "Importo" all the 3 records.
     
    The "Onselect" property of the button, applying your suggestion, is this (but i can made an error...)
    Patch(SpeseV01;
     ForAll(Gallery3.AllItems As _Data;
     
           {ID: _Data.ID;  
            Title: txtTitolo.Value;
               TipoSpesa: dropTipoSpesa.Selected;
               Importo: numImporto.Value;
               DataSpesa: dateDataSpesa.SelectedDate;
               Pagamento: dropPagamento.Selected;
               Fornitore: txtFornitore.Value;
               Note: txtNote.Value;
               DataRimborso: dateDataRimborso.SelectedDate;
               IDRimborso: txtIDRimborso.Value
               })
               
       )
     
  • WarrenBelz Profile Picture
    WarrenBelz 144,609 on at
    Using Patch and LookUp to udpate a Sharepoint list
    What part are you having trouble understanding ?
  • ancorte Profile Picture
    ancorte 84 on at
    Using Patch and LookUp to udpate a Sharepoint list
    Thank you Warren !!!
    It's all ok and it works perfectly ! I think that i have to understand better  how to use the patch function. Any suggestion will be appreciated !
  • Verified answer
    WarrenBelz Profile Picture
    WarrenBelz 144,609 on at
    Using Patch and LookUp to udpate a Sharepoint list
    The fundamental issue here is that you cannot Patch from the Collection while referring to the control values in the Gallery - either do one or the other - Patch from the Gallery and refer to the control content
    Patch(
       SpeseV01;
       ForAll(
          Gallery01.AllItems As _Data;
          {  
             ID: _Data.ID
             Title: _Data.txtTitolo.Value;
             TipoSpesa: _Data.dropTipoSpesa.Selected;
             Importo: _Data.numImporto.Value;
             DataSpesa: _Data.dateDataSpesa.SelectedDate;
             Pagamento: _Data.dropPagamento.Selected;
             Fornitore: _Data.txtFornitore.Value;
             Note: _Data.txtNote.Value;
             DataRimborso: _Data.dateDataRimborso.SelectedDate;
             IDRimborso: _Data.txtIDRimborso.Value
          }
       )
    )
    or Patch from the Collection and refer to the field names in it (I have assumed the names here)
    Patch(
       SpeseV01;
       ForAll(
          MyCollection As _Data;
          {  
             ID: _Data.ID
             Title: _Data.Title;
             TipoSpesa: _Data.TipoSpesa;
             Importo: _Data.Importo;
             DataSpesa: _Data.DataSpesa;
             Pagamento: _Data.Pagamento;
             Fornitore: _Data.Fornitore;
             Note: _Data.Note;
             DataRimborso: _Data.DataRimborso;
             IDRimborso: _Data.IDRimborso
          }
       )
    )

    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn    Buy me a coffee

     

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

End of Year Newsletter…

End of Year Community Newsletter…

Tuesday Tip #12 Start your Super User…

Welcome to a brand new series, Tuesday Tips…

Tuesday Tip #11 New Opportunities…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 144,609

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,420

Leaderboard