cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AaronDubin
New Member

Modify Dynamic Content Before Use in Flow

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!

1 ACCEPTED SOLUTION

Accepted Solutions
v-micsh-msft
Community Support
Community Support

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):

33.PNG

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:

35.PNG

Then save the flow and test it out.

My results:

36.PNG

Some reference:

Workflow Definition Language

If you have any further questions, please post back.

Regards

 

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

8 REPLIES 8
v-micsh-msft
Community Support
Community Support

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):

33.PNG

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:

35.PNG

Then save the flow and test it out.

My results:

36.PNG

Some reference:

Workflow Definition Language

If you have any further questions, please post back.

Regards

 

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

i don't know why but, on my environment doesn't work

i think i've done everything right...

 

http://imgur.com/a/oDkSI

 

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!!

Flowhelpplease
New Member

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!

Anonymous
Not applicable

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...

Anonymous
Not applicable

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

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Users online (2,703)