web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Rebuilding a collectio...
Power Apps
Answered

Rebuilding a collection with titles that include increasing seq no

(0) ShareShare
ReportReport
Posted on by 260

Just can't get this just rigjt.

I have an app that allows the uer to add items to a collection.  When added, the app creates a title like "Item 1, Item 2, Item 3, ..." using a global variable to use as in "Item " & varSeqNo.  But a user can also delete items from the collection, so a possible result could be "Item 1, Item 3, Item 4, Item 5" for example.  When an item is deleted, I want to regenerate the titles so there are no gaps.

I started with a ForAll(colItems,.. but can't patch the items in that collection of course.  So Itried a trick to create a new collection as in ClearCollect(colSwap, colItems) then do a ForAllcolSwap) patching colItems. But then no variable in that ForAll.

I tried this: ClearCollect(colSeq, {SeqNo:1}) and then iniside the ForAll(colSwp,  include a

Patch(colSeq, First(colSeq), {SeqNo: SeqNo+1}

Probably out of desperation.

 

Another approach was to use ForAll(Sequence(1,1, cutrows(colItems),  and to Patch(colItems, ThisRecord, {Title:"Item " & ThisRecord}).

 

I have no vested interest in any of the above approaches, just want a solution to renumber the titles,  Thanks in advance for any help

Categories:
I have the same question (0)
  • madlad Profile Picture
    2,637 Moderator on at

    Hi! 

     

    If all you need is for the titles to be reorganized sequentially, something like the below formula could work:

    ClearCollect(
     colSeq, 
     ForAll(
     Sequence(CountRows(colSeq)), 
     {Title: Concatenate("Item ", ThisRecord.Value)}
     )
    );

     

    Hope this helps!

  • lmheimendinger Profile Picture
    260 on at

    Not really.  Here's why.  The collection contains an image along with the title so a ClearCollect doesn't work because I loose the images.  I played around a bit this morning by when a new item is created, adding it to a duplicate collection as welll as the one displayed in gallery.  But trying to do a ClearCollect for the gallery collection and finding the corresponding image in the duplicate collection is something I have not been able to master.

    Suggestions?

     

  • Verified answer
    madlad Profile Picture
    2,637 Moderator on at

    I see, this changes it up a bit.

     

    Patch only updates the records, so that may work. 

    Using a ForAll and Patch worked for me in testing, so maybe something like:

     ForAll(
     Sequence(CountRows(colSeq)), 
     Patch(
     colSeq,
     Index(colSeq, ThisRecord.Value),
     {Title: Concatenate("Item ", ThisRecord.Value)}
     )

     Let me know if this works!

  • lmheimendinger Profile Picture
    260 on at

    Thanks I'll try that variance.  My previous attempts at Patch did not work.

  • lmheimendinger Profile Picture
    260 on at

    YES  worked exactly as I wanted.  Thanks!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 366 Most Valuable Professional

#2
11manish Profile Picture

11manish 184

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 99 Super User 2026 Season 1

Last 30 days Overall leaderboard