cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Filter an array of attachements from a sharepoint list

Hello, I am trying to filter an array I have created to get the attachments from a SharePoint list.

What I am trying to do is make it so that when information is entered in the SharePoint list the flow will kick off and send the information from the list item in 3 separate emails. I have this working, the next step is to get the attachments and filter them by name to get attached to the emails. There should be two attachments to for each list item, both PDFs, one for Accounting and one for Insurance. The 3rd email is just a general email with some of the information from the list entry.

 

I have tried Filter Array, I cannot get it to return the results that I am looking for, it will still attached both items to the emails instead of the intended one for each email.

 

I followed this thread to get them both to attach to one email. https://flow.microsoft.com/en-us/blog/multiple-attachments-single-email/

 

Any help would be appreciated!

 

1 ACCEPTED SOLUTION

Accepted Solutions
fchopo
Super User
Super User

Hello @Anonymous 

You could use a switch statement, with different paths according to the first 3 letters of the file name, for example. Have a look at this sample:

 

accounting.png

 

 

According to the first 3 letters of the attachment's filename, flow goes to Accounting or insurnance branches, using the following expression:

substring(items()?['Apply_to_each']?['DisplayName'],0,3)

 

Hope it helps!

Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!

View solution in original post

4 REPLIES 4
fchopo
Super User
Super User

Hello @Anonymous 

You could use a switch statement, with different paths according to the first 3 letters of the file name, for example. Have a look at this sample:

 

accounting.png

 

 

According to the first 3 letters of the attachment's filename, flow goes to Accounting or insurnance branches, using the following expression:

substring(items()?['Apply_to_each']?['DisplayName'],0,3)

 

Hope it helps!

Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!

View solution in original post

Anonymous
Not applicable

@fchopoThank you for the assistance, I am encountering an error though, it says "Template validation failed: the template acction 'Switch' at line '1' and column '2810' is not vaild: "the template languages function 'items' must have at least one parameter.

 

Also what is in the compose function? I just put in the 'Display Name' from the Get attachment step.

 

 

Anonymous
Not applicable

So i was able to get it to work. For the compose I used the 'DisplayName' from the 'Get Attachments' then for the switch I used

substring(outputs('Compose'),0,3)

And it is now working.

 

The last question I have, is there a way to make it more idiot proof? So that the capitalization of the file name would not matter?

Anonymous
Not applicable

I also was able to solve this issue by using the 'toUpper' command to change the file names to all uppercase then change the switch to all upper case.

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!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (1,851)