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.
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 🙂
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