Skip to main content

Notifications

Power Apps - Building Power Apps
Unanswered

Best way to update a sequential value in Sharepoint

Posted on 26 Nov 2024 21:56:43 by 614
I have a user group that wants to automatically renumber items upon request.
 
Here is the requirement and underlying data.
 
List has a PriorityRank column. This is a numerical value that orders items. The values are unique. This is controlled both in the SP list as well as in Control input validation in the app.
 
Upon demand, the users want to order the list by the PriorityRank column and then update the PriorityRank to increments of 10.
 
I have a button building the initial collection sorted by PriorityRank and also adding a RowNo value that I can use to calculate the new value.
 
Now the real question:
What is the best way to update the SP list? 
 
I thought that if I reversed the order and worked through the collection that way, meaning updating the record with the largest value first, it would work. But it doesn't seem to.
 
Because there are a number of required fields, I included values for them since it's how you have to do it in a Flow so I assumed the same here.
 
Here is the Patch statement:
ForAll(
    colPriRankRevOrderModded,
    Patch(
        'DataSource',
        LookUp(
            'DataSource',
            ID = Value(ThisRecord.ID)
        ),
        {
            PriorityRank: ThisRecord.PriorityRank,
            Status: {Value: ThisRecord.Status.Value},
            'Due Date': ThisRecord.'Due Date',
            Description: ThisRecord.Description,
            Cynefin: {Value: ThisRecord.Cynefin.Value},
            Priority: {Value: ThisRecord.Priority.Value},
            Expectation: ThisRecord.Expectation
        }
    )
);
I know know that the collection has the full record for Status, Cynefin and Priority so my problem isn't there. The seven columns I'm patching are the only required fields in the SP list.
The one thing I'm aware that it could be is the Rich Text fields. Both Expectation and Description are Rich Text and I'm not aware if there is anything specific that needs to be done to get them to patch correctly.
 
The other thing could be that it doesn't do a formal commit between records and if that's the case, by the time it gets to the end of the loop, there are definitely going to be PriorityRank values in conflict. Which is really what I think it is.
 
So, any suggestions on how to force a 'commit' and the end of each loop pass?
Categories:
  • DCHammer Profile Picture
    DCHammer 614 on 26 Nov 2024 at 22:05:43
    Best way to update a sequential value in Sharepoint
    Should have read more. lol.
    ForAll doesn't just do it all at once, it iterates through the collection completely randomly.
     
    So, the answer appears to be NOT using ForAll since I can't control execution sequence and use another method.

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,129

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,797

Leaderboard