cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mauslyon
Regular Visitor

manage multiple attachments - 2nd newbie question

Hi all, 

My situation is as follow:

I receive a weekly status email - from a known sender ("X") with a title in the form "YYYY-MM-DD - Weekly report" - that includes several PDF attachments (named as "NAME1_FIXEDTEXT.PDF", "NAME2_FIXEDTEXT.PDF" and "NAME3_FIXEDTEXT.PDF") - where NAMEn is variable but FIXEDTEXT is costant.

An example would be Title: "2020-03-02 Weekly Report" attachments: "Errors_WeeklyReport_system1.pdf", "Warnings_WeeklyReport_system1.pdf" and "Delays_WeeklyReport_system1.pdf"

 

Now I would like to create a flow that, upon reception of that email (trigger = Outlook mail reception from "X" AND Title contains "Weekly Report") will perform the following actions:

A) Extract the date from the title (in this case DATE ="2020-03-02")

B) For every PDF attached then

    B1) rename the file to "a something DATE_NAMEx.PDF"(i.e add the date at the front and strip the "_FIXEDTEXT" form the filename - in my example the first attached file should became "2020-03-02_Errors.PDF"

    B2) save the file in a certain folder in TEAMS/Sharepoint

 

Now I was planning to create a flow started by the trigger above, then set three variables:

"Reportdate" = substring(triggerBody()?['subject'],5,10)

"StartFilename" = "DUMMY"

"EndFilename" = "DUMMY"

Then for every attachement 

Set "Startfilename" = first(split ("attachment filename", '_')

Set "EndFilename" = concat("Reportdate", ' _ ',"Startfilename") 

create a sharepoint file in the correct directory with name = "EndFilename"

 

Everything is ok but for the StartfileName statement that results in the statement being used as a string instead of being executed; so in my example the first StartFileName i'm getting is ="first((split(Errors_WeeklyReport_system1.pdf,'_'))"

What Am i doing wrong??

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
abm
Super User
Super User

Hi @mauslyon 

 

Thanks for the screen share. Following are the changes we did.

 

1. Split the filename with keyword

2. Added compose

3. Set the compose with concat with three varaibles

4. Finally set the compose in Sharepoint filename

 

Note: What we found out that SharePoint create file filename, by default '&' character is changed to '_'.

 

Thanks

 

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

View solution in original post

4 REPLIES 4
abm
Super User
Super User

Hi @mauslyon 

 

You mentioned in your example you are getting "first((split(Errors_WeeklyReport_system1.pdf,'_'))" as text? Is this supposed to be an expression?

 

If you could please post a screenshot of your flow and the error step that will be really helpful to analyse this.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials
mauslyon
Regular Visitor

Hi @abm,

thanks for the quick reply.

Yes indeed, the "first((split(Errors_WeeklyReport_system1.pdf,'_'))" was supposed to be an expression:

basically I was trying to split the filename in pieces (i.e string "Errors_WeeklyReport_system1.pdf" -> Array "Errors", "WeeklyReport" and "system1.pdf")

then select only the first item (i.e. "Errors") and discard the rest. 

then string concatenate with date, separator, and ".pdf" will (should) result in having the filename as "2020-03-26 - Errors.pdf"

Now I have some good and bad news.

The good news is that I made a variable for each step and I was able to run the flow correctly (well almost - see below); the flow now fires upon reception of the email and cycle thru the attachmnets as planned

The bad news is that the filename gets screwed and I think it has to do with characters like & and . 

Anyway I'm detailing the step below:

Suppose the variable ReportDate is correctly set up, in the loop I use variables StartFileName, ShortName, EndName as STRING, TestArray as ARRAY

 

1) Set StartFileName = <Attachment Name"

2) Set TestArray = split(variables('StartFileName'),'_')    

3) Set ShortName = first(variables('TestArray'))
4) Set EndName = concat(variables('ReportDate'),' - ',variables('ShortName'))
 

1) OK - Value of Variable = 'Data Completeness & Gate Closure_WeeklyReportPDF_TABLEAU.pdf'

2) OK - Array made of 3 items ['Data Completeness & Gate Closure', 'WeeklyReportPDF', 'TABLEAU.pdf']

3) OK - Value of Variable = 'Data Completeness & Gate Closure' 

4) KO - Value of Variable is "Data Completeness_Gate Closure" ### <Ampersand> is gone and replaced by <underscore>

in addition, if I change statement 4 as follow

 Set EndName = concat(variables('ReportDate'),' - ',variables('ShortName'), '.pdf')

that statement is saved without the '.pdf' part

 

 

 

 

 

 

 

 

 

 

Hi @mauslyon 

 

Thanks for the detailed description. Could you please post a screenshot of your flow? Also the expressions.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials
abm
Super User
Super User

Hi @mauslyon 

 

Thanks for the screen share. Following are the changes we did.

 

1. Split the filename with keyword

2. Added compose

3. Set the compose with concat with three varaibles

4. Finally set the compose in Sharepoint filename

 

Note: What we found out that SharePoint create file filename, by default '&' character is changed to '_'.

 

Thanks

 

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

View solution in original post

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

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 (934)