I am attempting to create a flow that will move O365 email attachments to a specific Sharepoint365 library. I started from the built in template for this task, but ran into an issue when a new file had the same name as an existing file.
To resolve this, I attempted to use a combination of the From field and the Received Time field to generate a unique filename. This produced an issue because the Received Time field includes several disallowed characters including colons and slashes. I would like to be able to substitute another character for these disallowed characters (for example underscores) to make the filename valid.
My current workaround is to utilize the MessageID as a unique ID. This should work, but is suboptimal as it makes the filename entirely useless to a human reader.
Is there a way for me to substitute or remove the invalid characters inside the flow?
Thanks!
Solved! Go to Solution.
Hi @AaronDubin,
Thanks for sharing the workarounds.
Yes, there is a way to format the datetime with the Workflow Definition Language:
Please follow the steps below:
1. Add the trigger first (or we may start with the template, then delete the Apply to each),
2. Add a compose action, then input the value shown as below (when add the Attachment Name content, the Apply to each is added automatically):
3. After the apply to each added, change the Compose Action input with the formula below:
"@concat(formatdatetime(triggerBody()?['DateTimeReceived'],'yyyyMMddhhmm'),item()?['Name'])"
4. Add the SharePoint Create File Action, specify the SharePoint URL and the folder, use the compose outputs as the file name, use the Content(Attachment content)Dynamic content as the File content:
Then save the flow and test it out.
My results:
Some reference:
If you have any further questions, please post back.
Regards
Hi @AaronDubin,
Thanks for sharing the workarounds.
Yes, there is a way to format the datetime with the Workflow Definition Language:
Please follow the steps below:
1. Add the trigger first (or we may start with the template, then delete the Apply to each),
2. Add a compose action, then input the value shown as below (when add the Attachment Name content, the Apply to each is added automatically):
3. After the apply to each added, change the Compose Action input with the formula below:
"@concat(formatdatetime(triggerBody()?['DateTimeReceived'],'yyyyMMddhhmm'),item()?['Name'])"
4. Add the SharePoint Create File Action, specify the SharePoint URL and the folder, use the compose outputs as the file name, use the Content(Attachment content)Dynamic content as the File content:
Then save the flow and test it out.
My results:
Some reference:
If you have any further questions, please post back.
Regards
i don't know why but, on my environment doesn't work
i think i've done everything right...
Hi ferrantid,
You are missing double quotes " " during start and end of the formula you need to have @concat formula in double quotes. Copy paste the below text including double quotes. From your screenshot, I can see that you have not mentioned double quotes.
"@concat(formatdatetime(triggerBody()?['DateTimeReceived'],'yyyyMMddhhmm'),item()?['Name'])"
cheers!!
I manage to duplicate this flow as described but when the file renames with the date and time stamp it saves in UTC format.
I had a quick search through the forums and everyone says that flow just works in UTC and changing the settings won't do anything. It has been suggested that the expression
addhours(utcnow(),9
be added to the flow to rectify this issue but i cannot figure out where to place this expression / formula without breaking the flow.
Please help!
Hello all
I've just come across this, and I think it may help with a problem I'm having.
I get tens of spreadsheets sent to me every month, all with filenames that are composed of random numbers.
This flow successfully moved them to my Sharepoint library and renamed it with the datestamp. How can I adapt this flow to name a file specifically so I can use formula in Excel to refer to it?
I would also like the flow to remove the existing filename completely before renaming it (in my example the original file was called Book1)
For example:
This Flow renamed my file:
201805240242Book1
Can I make the flow call the file:
PhoneDataParks
Any help would be appreciated
Thanks
Hello,
This flow is useful to me.
Though to make the file name more presentable how can we have the date and time stamps after the file name instead of having it before. I tried to have below changes done
From : "@concat(formatdatetime(triggerBody()?['DateTimeReceived'],'yyyyMMddhhmm'),item()?['Name'])"
To : "@concat(item()?['Name'],formatdatetime(triggerBody()?['DateTimeReceived'],'yyyyMMddhhmm'))"
The flow works and file gets saved but without my xlsm extension and does not open in excel.
Where am i going wrong.
@Anonymous Did you ever figure this out? I'm trying to do the same thing...
Hi @vscarpato1
Yes I did. Please see a separate post I created on the matter:
https://powerusers.microsoft.com/t5/Building-Flows/Renaming-files-using-a-Flow/m-p/250655#M24916
Daniel
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Announcing a new way to share your feedback with the Power Automate Team.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
User | Count |
---|---|
66 | |
23 | |
16 | |
16 | |
13 |
User | Count |
---|---|
116 | |
35 | |
32 | |
28 | |
26 |