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

Adding first ten characters of a file to folder path

Hello there,

 

I think this one is easy for professionals Smiley Happy

 

In my company, we get daily mails with attachments showing the production results of the former evening. There are two shifts in production, so we get one e-mail at 6pm of the first shift and the second e-mail at 2am of the following day from the second shift.

My flow saves the attachements in folders on a sharepoint, which have the naming yyyy-mm-dd.
I solved it whith the 

convertTimeZone(utcnow(),'UTC','W. Europe Standard Time','yyyy-MM-dd')

for the first e-mail (this function in folderpath creates automatically a folder with the current date).

While the second mail arrives on the next day, I use 

FormatDateTime(AddDays(convertTimeZone(utcnow(),'UTC','W. Europe Standard Time','yyyy-MM-dd'), -1), 'yyyy-MM-dd')

for the attachements to be placed in the same folder as the attachement from the first function.

 

These ones work fine, but there is a third e-mail, which normally is send in the morning at 9am - no problem when I use the first function, but on monday, there is a special case: I get a mail from fridays production as well as from sundays production. My first function copies both mails in the same folder, which is no problem but it is not correct and I do not like it... Smiley Frustrated

 

I am looking for a workaround to copy the friday mail attachement in the production day folder of friday, and the sunday mail attachement in the production day folder of sunday.

Luckily, the filenames start with the same characters as my folders do: yyyy-mm-dd_filename.xls. So I think, the easist way is to extract the first ten characters from the filename and copy the attachement in a folder on the sharepoint using these characters for the folderpath.

 

But unluckily, I do not find a function which cuts parts of the filename off. I tried "substring" but was not able to declare the filename as the textstring of the function:

substring(text: string, startIndex: integer, length: integer)

Can anybody help, either with a function to cut off the substring or with a completely different workaround?

 

Thanks in advance,

 

Goodmountain

 
 
4 REPLIES 4
Super User
Super User

Re: Adding first ten characters of a file to folder path

@Goodmountain-

Inside of the Apply to each loop where you are looping through the attachments, you can use the following expression:

 

substring(items('Apply_to_each')?['Name'],0,10)
 
While the Name is not available to you via Dynamic properties, you can still use it by referencing it in this way.
 
If this addresses your issue, please mark you post as Solved.
 
Scott
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
Goodmountain
Level: Powered On

Re: Adding first ten characters of a file to folder path

@ScottShearer

 

I'm sorry, it doesn't work:

 

When I try to replace the FormatDateTime expression in Folderpath Section with yours

error01.PNG

 

the following error message is shown: 

 

error02.PNG

 

 

In fact, I do not even know what that means, normally I have an idea when facing an error message...

 

Thanks anyway,

 

Goodmountain

Super User
Super User

Re: Adding first ten characters of a file to folder path

Can you post a screen shot of your Flow please?

 

Scott

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
Goodmountain
Level: Powered On

Re: Adding first ten characters of a file to folder path

Sure:

error03.PNG

 

 

It's a simple one. I tried replacing the formula then got the error message.

 

Regards,

 

Goodmountain

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow Community User Group Member Badge

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

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 Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 189 members 5,209 guests
Please welcome our newest community members: