I'm working on a Flow that automatically emails files added to a Sharepoint Library. The recipient of said files is determined by a four digit prefix on the filename which I'm checking against a Sharepoint List containing the four digit code and an associated e-mail address.
From the image above, I'm hoping to have something like Code+_ to account for an underscore in the filename. In the event we ever have five digit codes (or human error), I don't want 0123 to receive the emails intended for 01234. I've thought about just adding the underscore to the Code in the Sharepoint List, but for aesthetic reasons I'm not sure it'll fly internally.
With regards to the non-matching, you would either need to remove the filter from Get Items, and then use a condition within your Flow to set the status as either Sent or Failed. Alternatively you could have a second Get Items which has the negative filter. Rather than your filter being FIELDA eq MYVALUE, it would be FIELDA ne MYVALUE.
Another consideration is that your SHarePoint list could be Failed as the default value, therefore will only change to sent when it has been processed.
Hi @ac1drain the action Get Files, or Get Items will always return an array. So if you have multiple files which meet your filter criteria then you will get all of them back. You just then need to handle the multiple files, usually within the loop.
@MattWeston365Is it possible to work with the files that did not match the filter query? Currently, once a match is made, the file contents are pulled, sent in an email, and then a Sharepoint property I've called Status is updated to "Sent". I'd like to be able to update the property of the non-matched documents to "Failed".
@MattWeston365Sorry, if I may bug you one last time while we're on this topic... is it possible to build an array of attachments if there are multiple files with the same prefix?
@MattWeston365That was it, thank you! It's working as expected.
Hi @MattWeston365, thanks for sharing this. Reading through it makes perfect sense, but putting it into practice has me a bit stumped (sorry, I'm quite new to Flow). Are you able to tell me what I'm doing wrong from the image below? The Site Address are properly populated, just redacted for privacy.
Hi @ac1drain, what you're describing is perfectly possible. As long as you have a consistent delimeter between the Code and the Main document name then you're in a good position. The following method will work regardless of how many characters are in your org code.
In my Flow, I have used a manual trigger to start (obviously use whatever you need here), and then I Get Files (Properties Only) in order to process them. I then have something similar to you.
The first thing I call is "Get Items", however when I build my Filter Query, I use an expression called Split. Split allows me to take a string, and break it on a specific character. The result is that I then have a string array. So for example, if my document is called: 0123-V365Doc.docx, and I split on a hyphen (-) then this will be split into:
0123 - This is given an index of 0
V365Doc.docx - This is given an index of 1
I can then use that within my Filter query, where I split my string on a defined character, and tell it to use index 0. I know I'm talking geek here but stay with me, it will all make sense in a moment 🙂 My expression is:
Split(items('Apply_to_each_file')?['{Name}'],'-')[0]
Name is the filename, "-" is the split character, and [0] is the index
When it goes into my Flow, it looks like this:
Using this method, it won't matter if my code is:
0123
01234
012345
They will all be treated differently, and the correct lookup will be performed on the OrgCode list.
I hope that makes sense 🙂
Hi @ac1drain ,
If you have any problems while creating the flow, feel free to ask for help here.
Best regards,
Alice
Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @ac1drain
Your names will need to have some pattern else you will run into 0123 and 01234 related issues since startswith or even contains will be the same case
You would need to either have a column which has the exact name in it so you can perform an equals operation or
the name would have to start with
0123_ or 01234_ so you can do contains the code_ format
Regards,
Reza Dorrani
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Michael E. Gernaey
497
Super User 2025 Season 2
David_MA
436
Super User 2025 Season 2
Riyaz_riz11
244
Super User 2025 Season 2