cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
AaronDubin
Level: Powered On

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
Community Support Team
Community Support Team

Re: Modify Dynamic Content Before Use in Flow

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
Community Support Team
Community Support Team

Re: Modify Dynamic Content Before Use in Flow

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

ferrantid
Level: Powered On

Re: Modify Dynamic Content Before Use in Flow

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

i think i've done everything right...

 

http://imgur.com/a/oDkSI

 

raghu
Level: Powered On

Re: Modify Dynamic Content Before Use in Flow

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
Level: Power Up

Re: Modify Dynamic Content Before Use in Flow

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!

danielfeatley
Level: Powered On

Re: Modify Dynamic Content Before Use in Flow

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

Damco
Level: Power Up

Re: Modify Dynamic Content Before Use in Flow

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.

 

vscarpato1
Level: Powered On

Re: Modify Dynamic Content Before Use in Flow

@danielfeatley Did you ever figure this out? I'm trying to do the same thing...

danielfeatley
Level: Powered On

Re: Modify Dynamic Content Before Use in Flow

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
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 381 members 6,903 guests
Please welcome our newest community members: