Solved! Go to Solution.
Yes, you can replace <yourString> with variable, but don't forget the apostrophes around it.
With the condition, you have 2 choices:
1. If you don't need any action when there's no file, you can use just 'Apply to each' on the output of that action. It'll run only if some files were found, otherwise it'll be skipped (as 'to each' = 'to nothing').
2. If you need also some action when there's no file, you'll need a condition that will check if the 'value' output of that action is not an empty array (the 'value' output of 'Get files' is an array, either it has all the file information or it's empty = [] ). As condition by default can't compare arrays, you'll have to create an empty array variable and use it in the condition.
Hi @philalethes when you say "20201026_(005, 011) site.xlsx" do you mean there could be 7 files ranging from names "20201026_005.xlsx" to "20201026_011.xlsx"?
@Amanthaper Thanks for clarifying. I probably could have made that more clear.
The (005, 011) is an ID for a specific piece of equipment, it is not a range.
I am trying to take the id I already have saved in my string variable (my example was 005, 011) and check to see if any files contain that id. I hope that helps clear it up.
Thanks!
@philalethesI would extract 005, 011 from the Excel filename and remove the space from both values and compare them.
Below flow worked using your exact examples:
(1) Remove space from 005, 011:
@Amanthaper Thanks for the idea of comparing the strings without the comma!
The part I seem most hung up on right now, is I am trying to compare my "key" (005, 011) against all the files in a SharePoint library to see if any of the files contain that key.
I have so far tried writing the list of file names to an array, but I can't figure out how to compare my key, which is a string, against the items in the array. I keep getting errors about my results type being objects or strings instead of an array when I try a few different methods of making that comparison.
Any thoughts on that piece?
Thanks!
If you're trying to filter files from a library that contain a specific string in the file name, you can do that directly in the 'Get files' action using the OData Filter query, just put there filter in format:
substringof('<yourString>', FileLeafRef)
Replace <yourString> with the string you want to find in the file name and the action will return only the relevant files.
@tom_riha Interesting! Will I be able to use a variable in that query? The string "key" I am checking with is dynamically generated from a new file being created that is then stored in a variable.
Also, I will be using this in a branching Apply to Each logic, so if it finds a match it goes down the yes branch and if it doesn't find a match it goes down the no branch. Is there a way to use this filter method in conditional branching logic?
Thanks!
Yes, you can replace <yourString> with variable, but don't forget the apostrophes around it.
With the condition, you have 2 choices:
1. If you don't need any action when there's no file, you can use just 'Apply to each' on the output of that action. It'll run only if some files were found, otherwise it'll be skipped (as 'to each' = 'to nothing').
2. If you need also some action when there's no file, you'll need a condition that will check if the 'value' output of that action is not an empty array (the 'value' output of 'Get files' is an array, either it has all the file information or it's empty = [] ). As condition by default can't compare arrays, you'll have to create an empty array variable and use it in the condition.
@tom_riha Brilliant! Comparing the array to an empty array did the trick! Thank you for your help!
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!
User | Count |
---|---|
45 | |
45 | |
38 | |
35 | |
23 |
User | Count |
---|---|
48 | |
32 | |
32 | |
31 | |
29 |