cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ac1drain
Level: Powered On

Is it possible to use dynamic content and static content in a single condition value?

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.

 

flow.png

 

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.

2 ACCEPTED SOLUTIONS

Accepted Solutions
Super User
Super User

Re: Is it possible to use dynamic content and static content in a single condition value?

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:

ApplyToEach.PNG

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 🙂





Did my reply help? Please give it a thumbs up.
Did I answer your question? Please mark my post as a solution!
If you liked my response, please consider giving it a thumbs up. THANKS!


Proud to be a Flownaut!





Community Leader: Black Country PowerApps & Flow User Group

View solution in original post

Super User
Super User

Re: Is it possible to use dynamic content and static content in a single condition value?

Just looking on my mobile which isn’t great, but it looks like it’s the name of the apply to each in your expression. I’d renamed my apply to each to include the word file, whereas yours is just “apply to each”. Therefore, in your expression, it will be Apply_to_each

Give that a go. I’m just about to board a flight but will be back online in a couple of hours if you don’t get anywhere




Did my reply help? Please give it a thumbs up.
Did I answer your question? Please mark my post as a solution!
If you liked my response, please consider giving it a thumbs up. THANKS!


Proud to be a Flownaut!





Community Leader: Black Country PowerApps & Flow User Group

View solution in original post

10 REPLIES 10
Dual Super User
Dual Super User

Re: Is it possible to use dynamic content and static content in a single condition value?

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

 

 

Community Support Team
Community Support Team

Re: Is it possible to use dynamic content and static content in a single condition value?

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.

Super User
Super User

Re: Is it possible to use dynamic content and static content in a single condition value?

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:

ApplyToEach.PNG

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 🙂





Did my reply help? Please give it a thumbs up.
Did I answer your question? Please mark my post as a solution!
If you liked my response, please consider giving it a thumbs up. THANKS!


Proud to be a Flownaut!





Community Leader: Black Country PowerApps & Flow User Group

View solution in original post

ac1drain
Level: Powered On

Re: Is it possible to use dynamic content and static content in a single condition value?

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.

 

flow.png

Super User
Super User

Re: Is it possible to use dynamic content and static content in a single condition value?

Just looking on my mobile which isn’t great, but it looks like it’s the name of the apply to each in your expression. I’d renamed my apply to each to include the word file, whereas yours is just “apply to each”. Therefore, in your expression, it will be Apply_to_each

Give that a go. I’m just about to board a flight but will be back online in a couple of hours if you don’t get anywhere




Did my reply help? Please give it a thumbs up.
Did I answer your question? Please mark my post as a solution!
If you liked my response, please consider giving it a thumbs up. THANKS!


Proud to be a Flownaut!





Community Leader: Black Country PowerApps & Flow User Group

View solution in original post

ac1drain
Level: Powered On

Re: Is it possible to use dynamic content and static content in a single condition value?

@MattWeston365That was it, thank you! It's working as expected.

ac1drain
Level: Powered On

Re: Is it possible to use dynamic content and static content in a single condition value?

@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?

Highlighted
ac1drain
Level: Powered On

Re: Is it possible to use dynamic content and static content in a single condition value?

@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".

Super User
Super User

Re: Is it possible to use dynamic content and static content in a single condition value?

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.





Did my reply help? Please give it a thumbs up.
Did I answer your question? Please mark my post as a solution!
If you liked my response, please consider giving it a thumbs up. THANKS!


Proud to be a Flownaut!





Community Leader: Black Country PowerApps & Flow User Group

Super User
Super User

Re: Is it possible to use dynamic content and static content in a single condition value?

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.





Did my reply help? Please give it a thumbs up.
Did I answer your question? Please mark my post as a solution!
If you liked my response, please consider giving it a thumbs up. THANKS!


Proud to be a Flownaut!





Community Leader: Black Country PowerApps & Flow User Group

Helpful resources

Announcements
firstImage

New Ranks and Rank Icons in April

Read the announcement for more information!

firstImage

Better Together Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

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!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (4,718)