cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

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
Highlighted
Super User III
Super User III

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
Highlighted
Frequent Visitor

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

Highlighted
Super User III
Super User III

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
Highlighted
Frequent Visitor

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

Super User Program Update

Three Super User rank tiers have been launched!

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

Join the new Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

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

Top Solution Authors
Users online (6,860)