I am grabbing a list of libraries and using that list as input for an "apply to each" loop that uses "get files (Properties Only)" , and filtering for old modified dates, I want to email the associates who last modified the file to update the file.
But it seems like I lose all the metadata and properties as dynamic content when my "get files (Properties Only)" is in a loop.
If someone could help me pull out data using expressions or tell me a better way to iterate through multiple files in multiple libraries it would be appreciated.
Solved! Go to Solution.
No problems, @Caspar_Rubin !
If you think about this slightly differently, @JustWorking, you could take the thought process that there's very likely going to be less users involved in modifying more documents than there are going to be as many users as there are documents.
So it stands to reason you'd actually economise here if you only sent a single email to each user.
So, alongside the Select that I intimated previously, you could have a parralel Select task that makes a list of purely users' emails. Then run your Apply to each loop on that (you just union the parallel Select) which then sends an email to each user that has modified many files in many locations.
This way, each user would only get one email or Teams message which means less harrasment on their end. Plus, in later versions of this flow, you could even have it ask them if a particular file can just be deleted or archived. This would then handle that for you, too. 👍
Anyway, I'll try to draw up a rough idea of how that would look for you, but ... yeah ... I think the more that you play with it, the more you'll figure out is possible here.
EDIT
Here's a look at something that I cobbled together on this, folks (to make the 'Map' field one box, tap the little 'T' icon to its right )
|
That union() in the 'Select an output from previous steps' field is: |
|
Hey,
not sure if I understand correctly but what if you try to use a string or array variable.
A variable is basically a container to store data in during loops so you don't lose it. You can then access all that gathered data after the loop is finished to, for example, send out and e-mail.
Basically you create a new variable (initialize variable action) at the top level. It's empty at the start but every loop it does inside the "apply to each" action, you add dynamic values to it (append to string (or array) variable action.
This is an example flow. I get all the titles from all the files in a library into a single string, separated by comma:
Above flow outputs this in the compose: All titles separated by commas.
does this help?
cheers
Somewhat, I have say 20 SharePoint document libraries with hundreds of documents each. I want to in one flow to search all the libraries, for all files that haven't been modified in xx days, email the address associated with the file. But if I use an "apply to each" loop to iterate through the records for the "get files (properties only)" step. I can't use dynamic content to pull out the file's information I need. So I am getting output with all the file information. But can't access it. I need dynamic content like below. If I am to email each associate that their file needs updating, I need access to file name, modified, modified by, email address.. In other words I have the needed information but I can't utilize it for the next step.
This is just pulled from a test flow, to generate these screenshots. There is normally a ton of information you can pull using "get files (Properties only)", but not if it is embedded in a 'apply to each loop"
I understand. For that, you'd have to manually get that information using expressions.
So instead of using dynamic content, you need to use expressions like this:
results in:
Note, some loops will fail, that's fine. You can either ignore that or implement a condition to skip empty files, libraries and stuff like that.
cheers
edit: added a screenshot
First, let me say thanks. For you to take the time to send all that information, it is appreciated. I will do some testing today.
Hi, @JustWorking, if you place a select item directly after that Get files you can create a more accessible array of data.
See this example below, you can see that I've made my own fields, and selected what is important to me:
|
To get the email address of a user you want to call the Editor/Email key and that will give that information.
Then you can filter accordingly.
Also give some thought to filtering your 'Get files...' request. 👍
No problems, @Caspar_Rubin !
If you think about this slightly differently, @JustWorking, you could take the thought process that there's very likely going to be less users involved in modifying more documents than there are going to be as many users as there are documents.
So it stands to reason you'd actually economise here if you only sent a single email to each user.
So, alongside the Select that I intimated previously, you could have a parralel Select task that makes a list of purely users' emails. Then run your Apply to each loop on that (you just union the parallel Select) which then sends an email to each user that has modified many files in many locations.
This way, each user would only get one email or Teams message which means less harrasment on their end. Plus, in later versions of this flow, you could even have it ask them if a particular file can just be deleted or archived. This would then handle that for you, too. 👍
Anyway, I'll try to draw up a rough idea of how that would look for you, but ... yeah ... I think the more that you play with it, the more you'll figure out is possible here.
EDIT
Here's a look at something that I cobbled together on this, folks (to make the 'Map' field one box, tap the little 'T' icon to its right )
|
That union() in the 'Select an output from previous steps' field is: |
|
I like the idea of building variables. But the only options I have when I use the "select" is "output". Remember the "get files (properties only)" is embedded in a "apply to each" loop. This is a nested loop because I have multiple libraries and that seems to impact the output coming from the "select" as well as the "get file (properties only)".
I'm struggling with the filter array. It doesn't seem to want let me select a dynamic content from the "Select Data" step. It also wants to put it in a apply to each loop automatically when I try and filter the array because it sees it as an array. Possibly I'm missing something. I know it's been a while but any help would be apprciated.
User | Count |
---|---|
102 | |
38 | |
31 | |
24 | |
16 |
User | Count |
---|---|
132 | |
53 | |
52 | |
37 | |
26 |