Ah yes. Bulk edits. The tedious job we hand off to interns.
Let’s say we have a SharePoint library with 15000 documents. In this list there is a ‘Document owner’ field. But… people move/get other jobs/win the lottery and won’t be around till the end of time. How can we easily change the document owner to his/her replacement?
- One at a time is definitely out of the question. This will take your poor intern days to process.
- In SharePoint you could use the excel like edit function. This will allow you to edit 100 items at a time, but it is reeeallly slow and clunky and it’s easy to make errors this way.
- You could use PowerShell. This is an excellent solution, but for this you’ll need proper Tenant credentials (which in most cases you won’t have) and even worse… you need to know how to write PowerShell scripts.
Luckily, Flow can do this as well. And you can even make it so ‘normal’ users can use it.
Step by step explanation
- Manually trigger the flow with a button press. On button press fill out the original email address and the email address you want to replace it with.
- In this compose action we’ll make the query. The Query states:
[ColumnName]/Email eq [email address]
Which translates to: give us all the items with the same emailaddress as given at the start of the flow
- Now to get the files we need to change. We’ll add the compose output we made in step 2 and add this in the Filter Query. You could put a query in this field directly, but when you use variables in your query this will give you a syntax error.
- Here we actually change the email address to the ‘to be replaced’ email address we added earlier. Once you add this, you’ll get an ‘Apply to each’.
NOTE!! The Apply to each has an item limit of 5000. So what happens when your library has more items?
The ‘Apply to each’ only targets the items from the Filter query. So as long as the result set from the ‘Get Files’ from step 3 is below 5000 items there shouldn’t be any problem.
To do the bulk edit, the only thing you have to do is start the flow, fill out the original email address and the email address you want to replace it with and flow will do the rest of the work for you. And even if it changes 5000 items, it will only cost you one Flow run!!!