cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dhalpin
Helper III
Helper III

Patch from a filtered Gallery

Hi all, 

 

I am trying to get Powerapps to Patch existing Sharepoint list items, but I'm having trouble with syntax/concept.

 

Current State:  The Sharepoint list contains 3 descriptors, "Collection Name", "Category", and "Item Name".  Within Powerapps I have a dropdown menu for "Collection" and another for "Category".  Gallery1 then shows "Item Name" by using:

Filter('Collection Name' = dropdown1.selectedText.value && Category = dropdown2.selectedText.Value)

 

I now want to use a 3rd dropdown to specify the Project Lead and have a "Submit" button Patch the relevant Sharepoint list items (whatever was showing in Gallery1).  I have all the dropdowns working fine, but I can't figure out how to code the Patch function to operate only on the items shown in Gallery1.   My current (non-functional) attempt is this:

 

ForAll(Gallery1.AllItems, Patch('SharepointList', Filter(CollectionName=dropdown1.SelectedText.Value && Category=dropdown2.SelectedText.Value), {'Project Lead': "test"}))

 

Sharepoint List:

Project LeadCollection NameCategory
Item Name
 Collection1Wood

ItemA

 Collection1WoodItemB
 Collection2SteelItemA
 Collection2SteelItemB
 Collection3WoodItemA
 Collection3WoodItemB
    
    

 

 

Hoping for some guidance!

 

dh

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Super User III
Super User III

Hi @dhalpin ,

You need to first "match" the records - I used ID as I assume it will be somewhere in the gallery data set,

The As statement is to avoid ambiguity - I included another field (Category) to demonstrate the syntax.

ForAll(
   Gallery1.AllItems As MyPatch, 
   Patch(
      'SharepointList', 
      {ID:MyPatch.ID},
      {
         Category:MyPatch.Category,
         'Project Lead': "test"
      }
   )
)

 

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.

 

View solution in original post

4 REPLIES 4
WarrenBelz
Super User III
Super User III

Hi @dhalpin ,

You need to first "match" the records - I used ID as I assume it will be somewhere in the gallery data set,

The As statement is to avoid ambiguity - I included another field (Category) to demonstrate the syntax.

ForAll(
   Gallery1.AllItems As MyPatch, 
   Patch(
      'SharepointList', 
      {ID:MyPatch.ID},
      {
         Category:MyPatch.Category,
         'Project Lead': "test"
      }
   )
)

 

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.

 

View solution in original post

Thank you @WarrenBelz !  Worked great. 

One small followup question:

 

This solution patches a Project Lead name to ALL the items in Gallery1.  There is a chance some would not be assigned yet, so there needs to be some IF(...) test.  A Collection ("Collection 1") is already being created by the app, and sub-components are being specified for each item in Gallery 1.  In that Collection1, Gallery1.Selected.ItemDescription is captured for each sub-component so how about something like this:

 

ForAll(
Gallery1.AllItems As MyPatch,
If(
Gallery1.selected.itemDescription exists in Collection1,


Patch(
'SharepointList',
{ID:MyPatch.ID},
{
Category:MyPatch.Category,
'Project Lead': "test"
}
)
)

Hi @dhalpin ,

Assuming the field names are the same

ForAll(
   Gallery1.AllItems As MyPatch,
   If(
      ItemDescription in Collection1.ItemDescription,
      Patch(
         'SharepointList',
         {ID:MyPatch.ID},
         {
            Category:MyPatch.Category,
            'Project Lead': "test"
         }
      )
   )
)

 

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.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (45,971)