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 / Powerapps :patch multi...
Power Apps
Unanswered

Powerapps :patch multi items collection to sharepoint in the same order they are collected

(1) ShareShare
ReportReport
Posted on by 18

Hi,

I collect data in a collection with a multiform powerapp.

I would like the collected items be patched in sharepoint in the same order they are collected because I use the generated ID later in a gallery .

The collection is in the right order but in sharepoint the ID generated are not in the same order.

Does anyone have an idea?

Thank you in advance

 

Laurence

Categories:
I have the same question (0)
  • TheRobRush Profile Picture
    11,128 Moderator on at

    you should share how you collected them the patch, etc so people know where you are and can help determine where you went wrong

  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    Relying on SharePoint-generated IDs can be risky, especially if multiple users are adding records concurrently. IDs are assigned by SharePoint independently of the order in which records are patched, and they aren't guaranteed to be sequential if there are other users adding data at the same time.

     

    Instead of relying on SharePoint IDs, you can generate your own unique identifiers within Power Apps before patching the data to SharePoint. Here's how you can do it:

     

    First,

    Add a "UniqueId" Text Column in SharePoint List

    Before beginning with the Power Apps formula, ensure that you have added a new Text column called "UniqueId" to your SharePoint list.

     

    Then:

     

    Generate Unique Identifiers in Power Apps

    Before patching, you can generate unique identifiers for each record in your local collection (colMyCollection).

     

    ClearCollect(
     colUniqueIdCollection,
     ForAll(
     colMyCollection,
     {
     UniqueId: Text(Now(), "[$-en-US]yyyymmddhhmmss") & Text(Rand(), "[$-en-US]0000"),
     Column1: Column1,
     Column2: Column2
     // Add all other fields you intend to patch
     }
     )
    )
    

     

     

    Patch the Entire Collection to SharePoint

    With the collection prepared, you can patch it directly to your SharePoint list. 

     

    Patch(
     SharePointList,
     Defaults(SharePointList),
     colUniqueIdCollection
    )
    

     

     

    Use Generated Unique Identifiers for Sorting or Referencing

    Since you've patched the UniqueId to SharePoint, you can then sort your gallery by UniqueId to maintain the order of records based on when they were added to your Power Apps collection.

     

    SortByColumns(
     Filter(SharePointList, ...),
     "UniqueId",
     Ascending
    )
    

     

    See if it helps @Laurence_78 

  • Chris-D Profile Picture
    1,246 on at

    If you you Patch ForAll the IDs should come out in order, but the IDs are auto generated so there's no guarantee what they'll be. 

    I'd be interested to know why they need to be in order? There's probably something you can do in the second part of your app to improve this in a more reliable way. 

  • CU12121104-0 Profile Picture
    18 on at

    Hi,

    On a first screen ClearCollect(ColCouv;DistriForm.Updates)

    On a second screen I Collect (ColCouv;EvalForm.Updates) and reset EvalForm; changing Name, add data and Collect (ColCouv; EvalForm.Updates)...

    My ColCouv is seen as:

     

    Distribution ; data1; Data2; Data3......

    Item1; data1; Data2; Data3......

    Item2;data1; Data2; Data3......

    Etc...

    But once patch in sharepoint, the item2 is patched before the item1 for example , so the ID of item 1 is higher than item 2

    I hope this is more clear now...

     

    Let me know,

     

  • Chris-D Profile Picture
    1,246 on at

    @Laurence_78 , why does that matter?

  • CU12121104-0 Profile Picture
    18 on at

    Hi,

    Imagine a book, with a distribution data, cover, and page 1,2,3 until 8, with parameters to fill for each page:

    I want to be able to recall this book from my sharepoint and the corresponding gallery to display the pages in the right order to review each one of them in the right order, with a button passing to next ID ( next page) .

  • CU12121104-0 Profile Picture
    18 on at

    Hi, 

    Problem is I have A LOT of columns and wanted to avoid the formula where you type all of the columns...

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
Haque Profile Picture

Haque 84

#2
WarrenBelz Profile Picture

WarrenBelz 79 Most Valuable Professional

#3
Kalathiya Profile Picture

Kalathiya 40 Super User 2026 Season 1

Last 30 days Overall leaderboard