0

I have a SharePoint Online site that contains several document libraries, some of which use a custom content type named, "Legal." And the Legal content type contains a metadata field named, "Purge Date." I need to produce a flow (using us.flow.microsoft.com) that updates deletes documents on their Purge Date, but only for those libraries that use the Legal content type. I have successfully used the "Get files (properties only)" action to get and interrogate files from a document library, but I have to hard-code the library name. I tried using the "Get all lists and libraries" action to iterate through the lists and libraries, then pass the library name to a "Get files (properties only)" action, but that has not worked for me.

My most recent attempt looks like this: enter image description here

The Get all lists and libraries action looks like this:

enter image description here

I then use the Filter array action to filter the lists and libraries based on content type.

I then use an "Apply to each" action to find files whose Purge Date equals today's date (I have the date hard-coded, for now):

enter image description here

No files are being deleted, so I added logic the "If no" branch to update the document's Title field with a a debug statement, but don't know how to access the Title field:

enter image description here

Do you think I'm on the right path? Do you recommend a different approach? Thanks!

3
  • Hello Frank, I suggest you specify what is not working. If you have all libraries in the site, then it should be possible to go through them one by one and get files with the Legal content type. If you are new to Power Automate, using dynamic values as input in the LIbrary input in the Get Files action might be bit confusing as the output is not appearing as usable values in later actions. But its certainly not impossible for a begnner :)
    – RuneBH
    Jan 25 at 16:21
  • Thank you for your response RuneBH. Please see my update question
    – Frank
    Jan 25 at 17:40
  • And, yes, I am new to Power Automate
    – Frank
    Jan 25 at 17:48

1 Answer 1

0

You are on the right path for sure! So the logic is sound, just a few ins and outs you need to be aware of and learn. But if you can get your head around a flow like this a lot of possibilities will open up!

I did a quick and dirty POC of what you want to do and below is a screen shot and some comments. It does what you want: Iterate libraries on a site, for each library it gets all files and filter out any not with the correct content type and then finally check if the date field is a specific date.

Over all the flow looks like this (almost similar to yours): enter image description here

  1. Get all list and libraries

  2. Insert an Apply to each and put the "Value" called outputs('Get_files_(properties_only)')?['body/value'] in the Select an output field.

  3. Insert an action Get File properties and in the library name you put "DisplayName" value from the Get all lists and libraries action.

  4. Insert a Filter Array action and in the "From" control you put the Value from the Get file properties, in the first Value control you put this expression to get the name of the content type:

    item()['{ContentType}']['Name']

and in the last Value control you put the name of the content type (in my case its called "MyCT"). 5.Still inside the Apply to each library loop from step 2 you add another Apply to each loop to iterate through all documents with the correct content type. So in the Select value from control you put the body from the Filter array action. 6. In the Apply to each document loop you put a Condition action, and in the first Value control you put the following expression

item()['MyDateColumn']

where the "MyDateColumn" is the internal name of the date column. And in the second Value control you insert the date you want to check for. 7. Finally update the document metadata in true cases as per you requirements.

In case you dont know, you insert an expression by clicking on the little "fx" icon that appears when you click inside an action control.

2
  • 1
    RuneBH, you are just the genius I was looking for. You solution worked perfectly. Thanks so much! Now I need to figure out how to mark yours as "the answer"
    – Frank
    Jan 27 at 13:09
  • I have another question RuneBH (or anybody else): With the Filter array action occurring AFTER the Get files action, does that mean that every document in all document libraries will be processed? If so, would it make more sense to put the Filter array action that filters the libraries based on content type make sense? I am a software developer, so that question makes sense to me. But I am a Power Automate beginner, so I don't claim to know the answer
    – Frank
    Feb 1 at 16:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.