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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Top Solution Authors
Top Kudoed Authors
Users online (1,280)