Hi @julienvdc ,
In that case, I recommend you to create an ID control separated from the default IDs handled by SharePoint. I will share a quick example on how you can do it.
Knowledge base
For further reference, I'm sharing some blog posts that I wrote about topics discussed in this answer. It can be helpful for you or for other users that find this thread:
- Writing expressions in Power Automate: http://digitalmill.net/2024/02/27/writing-expressions-in-power-automate/
- How to extract and clean texts with Power Automate: http://digitalmill.net/2023/08/12/how-to-extract-and-clean-texts-with-power-automate/
- Data types in Power Automate: http://digitalmill.net/2023/08/03/data-types-in-power-automate/
- Working with variables in Power Automate: http://digitalmill.net/2023/07/03/working-with-variables-in-power-automate/
SharePoint folder overview
For this example, we will be working with the following SharePoint folder:

All files created inside this folder follow a default naming convention: [file name] + "_ID" + [idNumber]. In our flow, we will create a new file, and the file name must follow this same convention, receiving the first integer number after the last existing idNumber.
If you want to just set the id number as file name, it will be even easier. Check my comments on the Step 2 about that 🙂
Step 1 - Get the last file created in the folder
Start by adding a "Get files (properties only)" action, selecting the site and folder (highlighted in blue) from where you want to return the file list. As advanced parameters, set the "Order by" as "Created desc" (highlighted in yellow) and the "Top Count" as 1 (highlighted in green):

These advanced parameters will ensure that only the most recently created file will be returned.
Step 2 - Isolate the current maximum id number
The latest created file will logically have the highest id. and we need to extract it in order to assign its value plus 1 to the file to be created inside this flow. Create an integer variable, and assign an expression to its value:

The expression is: int(last(split(outputs('Get_files_(properties_only)')?['body/value'][0]['{Name}'], '_ID'))), where you must replace "_ID" (marked in red) for any other convention of your preference. In a quick summary, this expression does the following:
- returns the "Name" property from the first element from "Get files (properties only)" value property (which is an array)
- Splits this "Name" by "_ID" and captures its last part, which corresponds exactly to the number assigned to ID (in our example, this number must be 3)
- As this value has a string data type, transforms it into an integer, in order to allow a future sum operation
If you need additional instructions on each of the methods used in this expression, I will be happy in explaining in more details 🙂
If you want to just set the ID number as file name, you can simply use int(outputs('Get_files_(properties_only)')?['body/value'][0]['{Name}']) as expression.
Step 3 - Create file with new ID
Finally, you can add a "Create a file" action and populate it with the site/folder where the file must be stored. When setting the file name, assign the name that makes sense for you (in my case, I just called it as "file"), add the "_ID" (highlighted in green), as this is part of our name convention, and add an expression right after it (highlighted in yellow):

The expression is: add(variables('last_id'), 1), and you must replace the text marked in red by the dynamic content of the variable created in Step 2. This expression is simply increasing the existent latest id number by 1.
Output
The flow ran successfully:

And the file was created in the SharePoint folder with ID 4, as expected:

Let me know if it works for you or if you need any additional help!
-------------------------------------------------------------------------
If this is the answer for your question, please mark the post as Solved.
If this answer helps you in any way, please give it a like.
http://digitalmill.net/
https://www.linkedin.com/in/raphael-haus-zaneti/