Hi everyone - I am creating a collection from a SharePoint list which has an ID field that is auto-incremented with deleted rows accounted for. Meaning, the list right now is ordered like this:
1.
2.
3.
4.
13.
20.
In addition to creating the collection, I'm adding a few extra columns. The code looks like this:
//Grab and setup table of contents based on selections
ClearCollect(colDocumentTableOfContents,
AddColumns(
GenAIDocumentComponents,
GenAITitle,
"N/A",
GenAIType,
"N/A",
GenAIBlockText,
"N/A",
Zone,
"unassigned",
checkValue,
"unchecked",
checkFont,
"#000000",
ThisType,
BlockType.Value,
TypeColor,
Switch(BlockType.Value,"Image","#0307fc","Legal","#03fc20","Description","#f803fc","Technical","#fca103","#000000"),
NewID,
CountRows(colDocumentTableOfContents)
)
);
This creates my collection, importing the ID field with the numbers listed above. I also created a NewID field to attempt to fix my issue, but the value is 0 for each row.
The problem is that non-sequential IDs creates all sorts of issues for me. I need the numbers to be sequential, like this:
1.
2.
3.
4.
5.
6.
So, I added code underneath the above snippet to reorder the IDs:
//Re-initialize all IDs to ensure they are sequential
ForAll(
Sequence(CountRows(colDocumentTableOfContents)), Patch(Last(FirstN(colDocumentTableOfContents, Value)),{ID:Value});
)
The IDs remain the same:
1.
2.
3.
4.
13.
20.
I also tried this:
//Re-initialize all IDs to ensure they are sequential
ForAll(
Sequence(CountRows(colDocumentTableOfContents)), Patch(Last(FirstN(colDocumentTableOfContents, Value)),{NewID:Value});
)
But all NewID values remain at 0; patching is not working.
I've been trying to do this for 2 weeks with no end in sight. Can someone tell me what I'm doing wrong?
Thanks