I have a flow set up that creates a new file in OneDrive using a SharePoint list item's attachments whenever a list item is created or modified. I followed a tutorial online to the letter, but I'm running into an issue.
Once uploaded to OneDrive, the file loses its content and format and is essentially useless. It's created in the correct folder with the correct name, but the content itself is gone. I've tried this with PDFs and image files, and the same issue occurs.
Below is the layout for my flow.
Solved! Go to Solution.
As you save each attachment file to OneDrive add the file extension to the file name:
The expression to get the file extension is:
last(split(item()?['DisplayName'],'.'))
And in the File Name, don't for get to add the 'dot' before the file extension:
Each time a list item column is modified, and that list item contains attachments, the flow will create files in OneDrive. I don't know of a way to detect when a list item attachment has been changed such as attachment added, attachment updated or deleted.
Ellis
____________________________________
If I have answered your question, please mark the post as Solved.
If you like my response, please give it a Thumbs Up.
I found it difficult to follow your flow. However, take a look at the following example. It should help you in fixing the issue. The flow will save an MS forms file attachment to a SharePoint list item. The flow assumes that the forms file upload is a required field:
Note expressions below for json and the Get file metadata:
Inputting the json expression:
Get the file File extension:
last(split(outputs('Get_file_metadata')?['body/DisplayName'],'.'))
Create a SharePoint list item, add the forms file attachment to the item:
Ellis
____________________________________
If I have answered your question, please mark the post as Solved.
If you like my response, please give it a Thumbs Up.
As you save each attachment file to OneDrive add the file extension to the file name:
The expression to get the file extension is:
last(split(item()?['DisplayName'],'.'))
And in the File Name, don't for get to add the 'dot' before the file extension:
Each time a list item column is modified, and that list item contains attachments, the flow will create files in OneDrive. I don't know of a way to detect when a list item attachment has been changed such as attachment added, attachment updated or deleted.
Ellis
____________________________________
If I have answered your question, please mark the post as Solved.
If you like my response, please give it a Thumbs Up.
Hi Ellis,
Thanks for your solution! Initially, it was working, but as I've moved some elements around, I'm now getting an error in my flow that causes it to fail. The error occurs during the "Compose" action, and I get this message: "InvalidTemplate. Unable to process template language expressions in action 'Compose' inputs at line '0' and column '0': 'The template language function 'split' expects its first parameter to be of type string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#split for usage details.'."
Any advice?
Thanks!
Please share the flow and the expression for the compose action.
The split() function is complaining that the string it is trying to split is empty, it does not not contain any data.
Ellis
The expression for the compose action is:
Here's the flow:
For reference, the "Yes" conditional is almost identical, but with one or two different items that all work fine. The same error occurs with the Compose action in that pathway as well.
Basically, the idea of the flow is to take a form entry, log it on a specific SharePoint list based on the type of purchase made, attach a receipt to the list item, then copy that receipt to a specific folder in OneDrive. The email is my failsafe to let the user know that the whole process succeeded.
Originally, I had two separate flows: one for logging the purchase and attaching the receipt, and another for recreating the receipt in OneDrive. The whole process worked, but since it was split between two flows, I felt it was unreliable. I've tried to combine the two flows, basically recreating the 2nd inside the 1st, but now it generates the error.
Hope that helps!
I found it difficult to follow your flow. However, take a look at the following example. It should help you in fixing the issue. The flow will save an MS forms file attachment to a SharePoint list item. The flow assumes that the forms file upload is a required field:
Note expressions below for json and the Get file metadata:
Inputting the json expression:
Get the file File extension:
last(split(outputs('Get_file_metadata')?['body/DisplayName'],'.'))
Create a SharePoint list item, add the forms file attachment to the item:
Ellis
____________________________________
If I have answered your question, please mark the post as Solved.
If you like my response, please give it a Thumbs Up.
Yes, it got it to work! Thanks.
@JWMartin Wondering if you'd take a look at my question on preserving original file names that are uploaded to OneDrive?
User | Count |
---|---|
22 | |
15 | |
14 | |
10 | |
9 |
User | Count |
---|---|
43 | |
28 | |
24 | |
23 | |
23 |