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 / Patch Function to upda...
Power Apps
Answered

Patch Function to update multiple rows with same column Value, Selected from a gallery

(0) ShareShare
ReportReport
Posted on by 15

HI Expert,

I have Sharepoint list which has many rows of same mail ids / name . I have collected them in Gallery with a search view as well . Now i want to select a record and want to update all rows for selected data by using below function 

 

If(IsBlank(First(Office365Users.SearchUser({searchTerm:Gallery2.Selected.'Mail address'})).DisplayName),
Patch(CCH_BLR_RESOURCE_LIST
,
Filter(CCH_BLR_RESOURCE_LIST
,
'Name Requester' = Gallery2.Selected.'Name Requester'
)
,
Table({LMName:"Inactive"})
),
Patch(CCH_BLR_RESOURCE_LIST
,
Filter(CCH_BLR_RESOURCE_LIST
,
'Name Requester' = Gallery2.Selected.'Name Requester'
)
,
Table({Organization:Office365Users.ManagerV2(Office365Users.ManagerV2(Gallery2.Selected.'Mail address').mail).department})
))

 

@RandyHayes

Categories:
I have the same question (0)
  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Kashif1 

    Your formula will not provide what you need. 

    You can use the UpdateIf function to update a list conditionally.  However, it has very poor performance.

     

    So, consider the following to replace your formula:

    If(
     IsBlank(First(Office365Users.SearchUser({searchTerm:Gallery2.Selected.'Mail address'})).DisplayName),
     Patch(CCH_BLR_RESOURCE_LIST,
     ForAll(
     Filter(CCH_BLR_RESOURCE_LIST,
     'Name Requester' = Gallery2.Selected.'Name Requester'
     ) As _item,
     {ID: _item.ID,
     LMName:"Inactive"
     }
     )
     ),
     Patch(CCH_BLR_RESOURCE_LIST,
     ForAll(
     Filter(CCH_BLR_RESOURCE_LIST,
     'Name Requester' = Gallery2.Selected.'Name Requester'
     ) As _item,
     {ID: _item.ID,
     Organization: Office365Users.ManagerV2(Office365Users.ManagerV2(Gallery2.Selected.'Mail address').mail).department
     }
     )
     )
    )

     

    It too is not that performant and can be simplified to the following:

    With({_items: Filter(CCH_BLR_RESOURCE_LIST, 'Name Requester' = Gallery2.Selected.'Name Requester') },
     If(
     IsBlank(First(Office365Users.SearchUser({searchTerm:Gallery2.Selected.'Mail address'})).DisplayName),
     Patch(CCH_BLR_RESOURCE_LIST,
     ForAll(_items,
     {ID: ID, LMName:"Inactive"}
     )
     ),
     Patch(CCH_BLR_RESOURCE_LIST,
     ForAll(_items,
     With({_dept: 
     Office365Users.ManagerV2(
     Office365Users.ManagerV2(Gallery2.Selected.'Mail address').mail
     ).department
     },
     {ID: ID, Organization: _dept}
     )
     )
     )
     )
    )
    

     

    I hope this is helpful for you. 

  • Kashif1 Profile Picture
    15 on at

    Thanks @RandyHayes  It worked . May i know is it neccessary to have "ID"  field in the code ?

     

    With({_items: Filter(CCH_BLR_RESOURCE_LIST, 'Name Requester' = ThisItem.'Name Requester') },
     If(
     IsBlank(First(Office365Users.SearchUser({searchTerm:ThisItem.'Mail address'})).DisplayName),
     Patch(CCH_BLR_RESOURCE_LIST,
     ForAll(_items,
     {ID: ID, LMName:"Inactive"}
     )
     ),
     Patch(CCH_BLR_RESOURCE_LIST,
     ForAll(_items,
     With({_dept: 
     First(Office365Users.SearchUser({searchTerm:ThisItem.'Mail address'})).Department
     },
     {ID: ID, Organization: _dept, LMName:"Active", Lab_Name: Office365Users.ManagerV2(
     Office365Users.ManagerV2(ThisItem.'Mail address').mail
     ).department }
     )
     )
     )
     )

    I have modified it to ThisItem as part of gallery integerated icon 

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Kashif1 

    Yes, If you do not provide the ID then it will create a new record for each record.  When you provide the ID, it will update the associated record.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 335 Most Valuable Professional

#2
11manish Profile Picture

11manish 166

#3
sannavajjala87 Profile Picture

sannavajjala87 71 Super User 2026 Season 1

Last 30 days Overall leaderboard