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?