cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
steveajones45
Regular Visitor

ForAll in a collection - only save changed items

Good Morning,

 

I have created a simple application with a gallery that has a toggle switch and a text input. I have a 'save' button outside of the gallery that I want to save the collection of changes into. I have it working if after each change I click on the save button, however, I would really like the save button to capture all changes once the end-user has made all of the required changes.

 

My formula that works for each row is as follows:

 

Collect(CollectCollection2, {ValidationAuditId: Label8.text, OverrideFlag: Toggle1.Value, OverrideDescription: TextInput.Text})

 

I have tried the following formula, however, this returns the entire gallery even if there are no changes:

 

Clear(CollectCollection2);

ForAll(

Gallary3.AllItems,

Collect(CollectCollection2, {ValidationAuditId: Label8.text, OverrideFlag: Toggle1.Value, OverrideDescription: TextInput.Text}));

 

Is there a way just to capture the changed records in the collection? 

 

Thank you in advance.

 

Steve

1 ACCEPTED SOLUTION

Accepted Solutions
eka24
Super User
Super User

I suggest you use an editable grid. Check this from Reza:

https://youtu.be/8I0Pt_8I6k8?t=33

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

View solution in original post

3 REPLIES 3
C-Papa
Super User
Super User

Hi, for the elements that the user can change, change the OnChange property to the below. this means it records the whole item whenever the toggle or TextInput is changed. 

 

Collect(CollectCollection2, {ValidationAuditId: Label8.text, OverrideFlag: Toggle1.Value, OverrideDescription: TextInput.Text})

 

when you have your collection you can patch it to your data source using ForAll() and Pacth() for example,

 

ForAll(CollectCollection2 As MyUpdates, Patch([DATASOURCE],{ID: MyUpdates.ID},{[COL1]:MyUpdates.ValidationAuditId, [COL2]:MyUpdates.OverrideFlag.Value, [COL3]:MyUpdates.OverrideDescription}))

WarrenBelz
Super User
Super User

Hi @steveajones45 ,

How do you know what is changed? Your second code will certainly collect all the gallery. If for instance you had a checkbox called ckSave and checked each item you wanted saved, you could do this

Clear(CollectCollection2);
ForAll(
   Gallary3.AllItems as aCol,
   Collect(
      Filter(
         CollectCollection2,
         ckSave.Value
      ), 
      {
         ValidationAuditId: aCol.Label8.Text, 
         OverrideFlag: aCol.Toggle1.Value, 
         OverrideDescription: aCol.TextInput.Text 
     } 
   )
);

 

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.

 

eka24
Super User
Super User

I suggest you use an editable grid. Check this from Reza:

https://youtu.be/8I0Pt_8I6k8?t=33

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (5,094)