I have a goal of being able to auto assign a unique, configurable, and sequencial document ID whenever a document is added to a particular SP library.
I hope I have not gone overboard on "needs & wants" but, being new to this, I wanted any potential responder to have enough details to know exactly what I'm looking for. Much appreciation for the help of experts and other users.
dbSeattle
Hi @dbSeattle,
Do you want the flow to auto-generate an ID for a file with Current Year, a set of numbers and rename the file with the ID?
Please take the following workaround for a reference.
It is triggered by When a file is created in a folder.
Add Compose action to get current Year with the following code:
Utcnow(‘yyyy’)
Add action Get files (properties only).
Add Compose 2, use the following code to get the total number in the library:
length(body('Get_files_(properties_only)')?['value'])
Add Compose 3, use the following code to generate the ID:
concat(outputs('Compose'),'123',add(outputs('Compose_2'),1))
Add create file action to rename the file with the ID generate from the previous step.
Finally, delete the original file.
Image for your reference:
If possible, that ID should be auto-inserted into an existing field on the form
Do you want to insert the Id in a column of the library? Please use the Update file properties action to update it to the specific column.
The ability to change the number or remove the document from the library should be restricted to a very limited number of individuals, perhaps only a Site Collection Admin.
Please consider using Send HTTP request to SharePoint to set custom permissions, please check the following doc for a reference:
Best regards,
Mabel
Do you need the numbers to start over again at 1 the the beginning of each year?
Do you need the length of the string that is generated to be constant. So, for example, do you need the ID to look like 2018-0001 or is it OK to have it look like 2018-1 ?
Your requirements regarding who can edit and delete documents can be handled by setting appropriate SharePoint security on the library. It does sound like you'll need to create a custom permission level that allows people to add documents but not edit or delete them. However, SharePoint does not offer column level security. In other words, you cannot prevent someone who has the ability to edit the document from changing the ID. There are a few tricks you can use to make it more difficult (make the column hidden, don't allow datasheet view, etc.) but you cannot prevent someone from editing a column if they have contribute access or greater.
Also, I agree with most of the solution proposed by @v-yamao-msft but I believe that it may generate duplicate IDs if one or more documents are deleted from the library.
Scott
Hi @ScottShearer ,
I have a similar issue and I am hesitant to start a new thread. I need a "counter" to append at the end of the following taxonomy:
yr/mm service type code counter
1904 123 01
1904 123 02
1905 123 01
1905 456 01
1905 456 02
1905 789 01
Basically, the counter resets by yr/mm and by type of service code and combined there can't be duplicates of the final unique ID - '190512301' for example. I appreciate any insight to this. I've scoured several articles but I'm having a hard time applying these 2 conditions to program a "counter".
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!
User | Count |
---|---|
13 | |
12 | |
11 | |
7 | |
6 |
User | Count |
---|---|
20 | |
16 | |
14 | |
10 | |
9 |