web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Problem with Patch ins...
Power Apps
Answered

Problem with Patch inside Gallery AllItems

(0) ShareShare
ReportReport
Posted on by

Hello, I have a problem with making a patch from the gallery to SharePoint.

This is my app and gallery:

Palucci12_0-1719586124621.png

This is SP List:

Palucci12_1-1719586157854.png

I would like to update all the elements entered in the gallery, if I do not change the values, then they will remain the same as they were saved in SP.I have this code but it doesn't work properly, I don't know why. It changes only one line of code, usually the first one. Does anyone of you know why and can help me?

 With(
 {SelectedItem2: Gallery5.AllItems},
 ForAll(
 SelectedItem2 As Item2,
 Patch(
 ev_List_Sharepoint_Milestone,
 LookUp(
 ev_List_Sharepoint_Milestone,
 'Contract Number' = Item2.'Contract Number' && 'Responsible Persons'.Value = Label7.Text
 ),
 {
 'Project Owner': If(
 Len(TextInput1.Text) > 0,
 TextInput1.Text,
 LookUp(
 ev_List_Sharepoint_Milestone,
 'Contract Number' = Item2.'Contract Number' && 'Responsible Persons'.Value = Label7.Text
 ).'Project Owner'
 ),
 'Reporiting Month': Text(
 Date(
 Year(
 DateAdd(
 Today(),
 -1,
 TimeUnit.Months
 )
 ),
 Month(
 DateAdd(
 Today(),
 -1,
 TimeUnit.Months
 )
 ),
 1
 ),
 "dd.mm.yyyy"
 ),
 'Partner 1': If(
 Len(TextInput1_1.Text) > 0,
 TextInput1_1.Text,
 LookUp(
 ev_List_Sharepoint_Milestone,
 'Contract Number' = Item2.'Contract Number' && 'Responsible Persons'.Value = Label7.Text
 ).'Partner 1'
 ),
 'Partner 2': If(
 Len(TextInput1_2.Text) > 0,
 TextInput1_2.Text,
 LookUp(
 ev_List_Sharepoint_Milestone,
 'Contract Number' = Item2.'Contract Number' && 'Responsible Persons'.Value = Label7.Text
 ).'Partner 2'
 ),
 'Partner 3': If(
 Len(TextInput1_3.Text) > 0,
 TextInput1_3.Text,
 LookUp(
 ev_List_Sharepoint_Milestone,
 'Contract Number' = Item2.'Contract Number' && 'Responsible Persons'.Value = Label7.Text
 ).'Partner 3'
 )
 }
 )
 )
 ),

Label7 is the label under the Responsible Person column in the application

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,793 Most Valuable Professional on at

    HI @Palucci12 ,

    If those Text Inputs and Labels are inside the gallery, they need Item2. in front of them.

     

    Please click Accept as solution 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 Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • Palucci12 Profile Picture
    on at

    Hello @WarrenBelz , 

    Thanks for your reply. If I understand correctly, I added Item2 to the label inside With. Unfortunately, it doesn't work properly because the first screen is the input data and the second one is the output data. That is, it takes one value in a column and overwrites it in all rows

     

     With(
     {SelectedItem2: Gallery5.AllItems},
     ForAll(
     SelectedItem2 As Item2,
     Patch(
     ev_List_Sharepoint_Milestone,
     LookUp(
     ev_List_Sharepoint_Milestone,
     'Contract Number' = Item2.'Contract Number' && 'Responsible Persons'.Value = <strong>Item2.Label7.Text</strong>
     ),
     {
     'Project Owner': If(
     Len(TextInput1.Text) > 0,
     TextInput1.Text,
     LookUp(
     ev_List_Sharepoint_Milestone,
     'Contract Number' = Item2.'Contract Number' && 'Responsible Persons'.Value = <strong>Item2.Label7.Text</strong>
     ).'Project Owner'
     ),
     'Reporiting Month': Text(
     Date(
     Year(
     DateAdd(
     Today(),
     -1,
     TimeUnit.Months
     )
     ),
     Month(
     DateAdd(
     Today(),
     -1,
     TimeUnit.Months
     )
     ),
     1
     ),
     "dd.mm.yyyy"
     ),
     'Partner 1': If(
     Len(TextInput1_1.Text) > 0,
     TextInput1_1.Text,
     LookUp(
     ev_List_Sharepoint_Milestone,
     'Contract Number' = Item2.'Contract Number' && 'Responsible Persons'.Value = <strong>Item2.Label7.Text</strong>
     ).'Partner 1'
     ),
     'Partner 2': If(
     Len(TextInput1_2.Text) > 0,
     TextInput1_2.Text,
     LookUp(
     ev_List_Sharepoint_Milestone,
     'Contract Number' = Item2.'Contract Number' && 'Responsible Persons'.Value = <strong>Item2.Label7.Text</strong>
     ).'Partner 2'
     ),
     'Partner 3': If(
     Len(TextInput1_3.Text) > 0,
     TextInput1_3.Text,
     LookUp(
     ev_List_Sharepoint_Milestone,
     'Contract Number' = Item2.'Contract Number' && 'Responsible Persons'.Value = <strong>Item2.Label7.Text</strong>
     ).'Partner 3'
     )
     }
     )
     )
     ),

    Input

     

    Palucci12_0-1719735027973.png

    Output

    Palucci12_1-1719735254739.png

     

  • Verified answer
    WarrenBelz Profile Picture
    153,793 Most Valuable Professional on at

    Hi @Palucci12 ,
    Again assuming all the Text Inputs are in the Gallery - this should give you some idea on structure

    ForAll(
     Gallery5.AllItems As Item2,
     With(
     {
     _Record:
     LookUp(
     ev_List_Sharepoint_Milestone,
     'Contract Number' = Item2.'Contract Number' && 
     'Responsible Persons'.Value = Item2.Label7.Text
     ),
     _Date:
     Text(
     DateAdd(
     Date(
     Year(Today()),
     Month(Today(),
     1
     ),
     -1,
     TimeUnit.Months
     ),
     "dd.mm.yyyy"
     )
     },
     Patch(
     ev_List_Sharepoint_Milestone,
     { 
     ID: _Record.ID,
     'Project Owner': 
     Coalesce(
     Item2.TextInput1.Text,
     _Record.'Project Owner'
     ),
     'Reporiting Month': _Date,
     'Partner 1': 
     Coalesce(
     Item2.TextInput1_1.Text,
     _Record.'Partner 1'
     ),
     'Partner 2': 
     Coalesce(
     Item2.TextInput1_2.Text,
     _Record.'Partner 2'
     ),
     'Partner 3': 
     Coalesce(
     Item2.TextInput1_3.Text,
     _Record.'Partner 3'
     )
     }
     )
     )
    )

     

    Please click Accept as solution 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 Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
Haque Profile Picture

Haque 70

#2
WarrenBelz Profile Picture

WarrenBelz 64 Most Valuable Professional

#3
Kalathiya Profile Picture

Kalathiya 36 Super User 2026 Season 1

Last 30 days Overall leaderboard