cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Morke
Helper II
Helper II

Help understanding dynamic increment

Hi

While looking for a way of adding a dynamic increment to my repeating gallery, I came across this solution:

 

https://powerusers.microsoft.com/t5/Building-Power-Apps/powerapps-dynamic-increment/td-p/299063

 

So I implemented it and it worked as a charm (except for a couple of adjustments I had to make because of my environment)

The thing is
I have no clue whats going on there.

Why on the close button we need to create a new collection from scratch with the same fields as the main one, if we are only going to use it inside this Close button functionality? What's the purpose of it?
And why are we doing a Clearcollect afterwards?

1 ACCEPTED SOLUTION

Accepted Solutions

@Morke 

The code sample that you refer to here accounts for the fact that the end user can remove an item in the gallery by clicking the remove icon.

In this instance, we need to renumber the items in the gallery because there will be one less item. That is the purpose of this code.

Hope that makes sense.

View solution in original post

3 REPLIES 3
timl
Super User
Super User

@Morke 

Can you confirm which formula you're referring to when you say the 'close button'?

Are you referring to the formula for the remove icon, as shown below?

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

Within the Gallery, add a "Remove" icon, set the OnSelect property to following:

Remove(RecordsCollection, ThisItem);
Clear(RecordsCollection1);
ForAll(
RecordsCollection,
Collect(RecordsCollection1, {Name: "Details-"& CountRows(RecordsCollection1)+1, TextBoxValue: TextBoxValue})
);
ClearCollect(RecordsCollection, RecordsCollection1)

 

@timl Yes, exactly, that formula.
Why is he creating a new collection only to be used there, in that formula?

@Morke 

The code sample that you refer to here accounts for the fact that the end user can remove an item in the gallery by clicking the remove icon.

In this instance, we need to renumber the items in the gallery because there will be one less item. That is the purpose of this code.

Hope that makes sense.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

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.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,517)