Hi folks,
I'm using a OneDrive for Business trigger On New File Created V2. There is a parameter called File identifier which comes from the header value x-ms-file-id. The output is not only the file id but also the driveid in the format: driveId.fileId
Example: b!gTp3wO20k0WtUmhuonLBuXtKRm1S13RNuuhZW7LPGGO5aH4qPCLyS6EC53Jw7wdh.02TZBWRJ7XXGSLXU4BIVHL4FNAQGY2V3RH
Currently I split this string by the dot (.) to get only the fileId part.
I wonder if this is correct behavior?
Thanks
Hi @SvenG ,
Could you please explain more details about your requirement?
Best regards,
Alice
Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Alice,
I just need the OneDrive fileId
Thanks
Sven
Here is what I found, there is no simple way to do this as of now. Here are the two methods I leverage and what I did. I would recommend the alternative as you get more tools in your toolbox. But for a direction solution the first method would get you there:
I use the x-ms-file-id this has the path of the file that is being accessed. Be aware that '/' is '%252f' and a space (' ') is '%2b'. Due to this change in order to use anything with "using path" I had to change this. Using the replace function twice did that for me it would look something like this:
replace(replace(triggerOutputs()?['headers/x-ms-file-id'], '%252f', '/'), '%2b', ' ')
this would provide a file path from parent%252fchildFolder%252fFile%2bNeeded.txt to parent/childFolder/File Needed.txt
Where do you put that double replace function above:
Place it into "Get file metadata using path", the result of "get file metadata using path will result in you having the FileID
You will also see a trigger output called 'Headers'
triggerOutputs()?['headers']
inside of this, it is a JSON style/formatted list of information about the file that triggered the flow. Make a compose, put headers as the input, make a file and check the running of that flow you will see what I mean. You will see there is
x-ms-file-path
. If you can separate this out with a Filter Array or Select from "Data Operations" this would be the direct path without the need for what was explained in the "First Method". While neither of them is an easy starting point, I would recommend this method, filtering and parsing JSON data is much faster and seems to be used throughout Power Automate. There are numerous explanations of the use of Filter Array and Select throughout both power users' forums.
Both methods: will work on OneDrive or OneDrive for Business.
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
User | Count |
---|---|
30 | |
29 | |
27 | |
20 | |
11 |