cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
New Member

Condition to match multiple entries in a value

I am trying to perform one of two actions depending on the file extension of an uploaded file. If a file has one of several (around 12) extensions I want to perform Action A. if the file extension is anything else then I want to perform Action B.

I cannot use basic mode conditions in Flow because there are not enough rows for each of the file types, so I have tried using the more adfvanced Expressions option. I have put in the following syntax:

or(endsWith(triggerBody()?['{FilenameWithExtension}'],'.docx'),endsWith(triggerBody()?['{FilenameWithExtension}'],'.xlsx'))

but when I upload a docx file (or a pptx file) the result is always false, and only Action B ever gets performed. 

7 REPLIES 7
Highlighted
Super User III
Super User III

Re: Condition to match multiple entries in a value

Hi @JHA-MCT ,

 

Is this works for you? The first step pass your file extension. Second flow action extend all 12 extensions with comma separated. Finally check whether it contains?

 

contains.png

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up.

 

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 blog
Highlighted
Community Support
Community Support

Re: Condition to match multiple entries in a value

Hi @JHA-MCT ,

 

What is the trigger in your flow?

Could you please share a screenshot of the configuration of your flow?

 

Please check if the expression triggerBody()?['{FilenameWithExtension}'] could get a file name with expression without encoded, I afraid that the expression would give a encoded file name so the Condition would always with false result.

 

If the expression would give a encoded file name, you could add a get file metadata action to get the file name and then use it in the Condition.

Please let me know if your problem could be solved.

 

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.

 

Highlighted
New Member

Re: Condition to match multiple entries in a value

So I didn't know how to get the file extension out in the first place. I tried split() on the filename with extension like so: 

split(triggerBody()?['{FilenameWithExtension}'],'.')

Which appeared to work (from the test run). I then used last() to get just the extension (which shows as docx in the test run), however I then have a compose step to try to create the comparison array:

 

Flow-composeArray.png

And then the comparison step:

contains(outputs('Compose'),variables('fileExtension'))

However when I run it fails and I get an error about comparing an entry in the array:

 

Flow-arrayError.png

So I'm a bit lost - in the test run all the variables appear like strings, and appear to have the expected values in them.

 

Highlighted
New Member

Re: Condition to match multiple entries in a value

These are the initial steps I am doing when a new file is added to library:

 

Flow-initialSteps.png

Highlighted
Super User III
Super User III

Re: Condition to match multiple entries in a value

Hi @JHA-MCT ,

 

You need to use FilenameWithExtension property. Once you got the filename then use the split function to get the extension.

 

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 blog
Highlighted
New Member

Re: Condition to match multiple entries in a value

Hi @abm 

 

I tried that, but as you can see from my earlier reply, when I try to use contains() to match the extension, I get some kind of mismatch error.

Highlighted
Super User III
Super User III

Re: Condition to match multiple entries in a value

Hi @JHA-MCT ,

 

I have constructed a flow and tested this. Try the following:

 

Here first we need to set the trigger and initialise valid extensions.

 

a1.png

 

Next initialise a variable called Document Extension. Check whether user added a folder or file. Because in SharePoint users can create folders or upload a file under a particular folder / root of the library.

a2.png

 

Next we need to extract the uploaded file extension using split statment and compare the value against ValidExtension varaible we defined earlier. For the split function please copy this

 

split(triggerBody()?['{FilenameWithExtension}'],'.')[1]
 
See the below Yes condition flow action below.
 
a3.png

 

Next you can extend your logic under the Yes condition appropriately.

 

Here are my test results:

 

a4.png

 

If you need any further help please let me know.

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up.

 

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 blog

Helpful resources

Announcements
firstImage

Super User Program Update

Three Super User rank tiers have been launched!

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

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!

Top Solution Authors
Top Kudoed Authors
Users online (7,372)