I am creating a flow to take a file uploaded to Microsoft Forms and move the file to SharePoint.
As the file is moved to sharepoint, it will be renamed using the answers on the form where the file was uploaded.
I am able to move and rename the file using the answers but I am stuck when I try to add the file extension on the end, as it may be a different file type depending on the uploaded file.
So far it goes like this:
When a new response is submitted:
Form id: (Selected form)
Get Response Details:
Form id: (Selected form)
Response ID: Response Id (dynamic content)
List files in folder(OneDrive):
/Apps/Microsoft Forms/(Selected form)/Upload
At this point I was going to use an Apply to each to take the Value from the OneDrive file and use 'Compose' step to take the input Name(OneDrive) and have it output the name. Then 'Compose 2' step to separate the name from the extension and leave me with just the extension to use later on.
Compose:
Input: Name(OneDrive)
Compose 2:
input: Expression: last(split(triggerOutputs()?['body/Name'], '.')) <-----this expression doesn't properly output anything
The extension would be used when creating the file name in the next part
Apply to each:
(select an output from previous steps)
Value(OneDrive)
Get File content:
File: Id(OneDrive)
Create File:
Site Address: (Sharepoint site)
Folder path: (folder location where the file will be dropped)
File name: (Form Answer1)-(Answer 2).(output Compose2) <--- this is where the issue is
File Content: Body(OneDrive)
Delete File:
File: Id(OneDrive)
I originally added the "Media Type(OneDrive)" Dynamic content but it returns the type of media and extension.
Example: .application_pdf
Thank you, I will play around with it and try that out.
You could do it in one, but that's essentially what I was suggesting.
Thank you. I am sure you were talking about something a little more elegant, but I removed 'apply to each 2' and added the 'Compose' and 'Compose 2' to just after 'Get file content'.
In compose 2 I used the expression: Last(Split(outputs('Compose'),'.'))
Then added the Compose 2 output dynamic content to the end of the file name:
FormAnswer1-FormAnswer2.Compose2Outputs
Your answer helped a lot with my understanding! Much appriciated!
The file that is uploaded has a filename with extension already. You can use Split() on a '.' and Last to get the file extension of the existing file and then concatenate that to the new filename you want to use to rename the file when you create it.
WarrenBelz
146,745
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
66,091
Most Valuable Professional