cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
marc2510
Helper I
Helper I

Patch all items in a filtered Gallery

Hello,

 

Im struggling to work out a solution to patch all items in a filtered gallery.

this is what i use to patch a single record 

 

Patch(studenttrackermaster2,ThisItem,{Comments:TextInput1_2.Text},{maths_WorkCompletion:Dropdown2_2.SelectedText},{maths_engagement:Dropdown2_8.SelectedText})

I have attached an image for example
my unique field for each = "UPN"


 
 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @marc2510 ,

After our discussion and your renamed controls

ForAll(
   RenameColumns( 
      Gallery1.AllItems,
      "ID",
      "ID1"
   ),
   Patch(
      studenttrackermaster2,
      {ID: ID1},
      {Comments: TextComments.Text},
      {Art_WorkCompletion: {Value: ddCompletion.Selected.Value}},
      {Art_engagement: {Value: ddEngagment.Selected.Value}}
   )
)

 

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

14 REPLIES 14
WarrenBelz
Super User III
Super User III

Hi @marc2510 ,

This structure will do it

ForAll(
   Filter(
      YourGalleryName.AllItems,
      YourFilterHere
   ) As aFiltered,
   Patch(
      studenttrackermaster2,
	  {UPN:aFiltered.UPN},
	  {
         Comments:TextInput1_2.Text,
         maths_WorkCompletion:Dropdown2_2.Selected.xxx,
         maths_engagement:Dropdown2_8.Selected.xxx
      }
   )
)

 

Note xxx is whatever the .Selected. value is for the control (Value/Result/Field Name)

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.

Thank you for the swift reply!

currently the gallery is filter like so Filter(studenttrackermaster2,Maths.Value=Dropdown1_2.Selected.Value)

how would i add this for the gallery filter?

@marc2510 ,

No need to if your gallery is already filtered - I assumed you wanted to add a filter to it

ForAll(
   YourGalleryName.AllItems As aFiltered,
   Patch(
      studenttrackermaster2,
      {UPN:aFiltered.UPN},
      {
         Comments:TextInput1_2.Text,
         maths_WorkCompletion:Dropdown2_2.Selected.xxx,
         maths_engagement:Dropdown2_8.Selected.xxx
      }
   )
)

 

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.

marc2510
Helper I
Helper I

Sorry to be a pain but I'm getting this error? ( see attached)
again sorry!

 

@WarrenBelz 

marc2510
Helper I
Helper I

To get rid of the error, I added Gallery1_1.Allitems


ForAll(
Gallery1_1.AllItems As aFiltered,
Patch(
studenttrackermaster2,
{UPN: aFiltered.UPN},
{
Comments: TextInput1_1.Text,
Eng_WorkCompletion: Dropdown2_1.SelectedText,
Eng_engagement: Dropdown2_7.SelectedText
}
)
)

but this then makes changes to all items on the list 

@marc2510 ,

I was using your values here as you posted that UPN was the common key between the tables. What type of field is UPN?

marc2510
Helper I
Helper I

UPN is the unique value given to each user (like an ID) 

 

UPN is just a text field.

 

I’m very grateful for all the support on this

 

 

@marc2510 ,

I have fixed the AllItems - dangers of free-typing.

Why are you getting the error that UPN was expecting a Table?

 

 

 

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.

marc2510
Helper I
Helper I

@WarrenBelz  The error has now gone when using the all items.
When i am using the ForAll function it is saving all the records the same instead of treating each row of data individually?

for example if i add a comment to the user with UPN 681 - it then changes all the other users comments to the same. I want it to save each row individually

form.PNG


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

PA Community Call

Power Apps Community Call

Next call is happening on April 21st at 8a PST.

MBAS Carousel

Sign up for our May 4th event!

May the fourth be with you, join us online!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors
Users online (62,438)