1

I am trying to use Power Automate to set up a Scheduled cloud flow which will delete all folders in a Document Library that are empty on a 30 day recurring interval. I followed the example found here: https://faustocapellan.com/2020/11/30/how-to-4-delete-empty-folders-in-sharepoint-document-libraries-using-power-automate/

I have simultaneously asked for assistance on that website as well, but the author doesn't appear to check the comments section very often. Hoping someone here can help.

I keep getting an error on the filter array with the body(‘GetFolders’)?[‘value’] expression. Keeps throwing an invalid expression error. It also gives me a pink function icon expression box and not the green sharepoint Value expression box shown in the example.
Mine:

enter image description here

Example:

enter image description here

Can anyone spot what is going wrong with this?

0

2 Answers 2

1

What did you call YOUR step to get the folders? The GetFolders part in body('GetFolders')?['value'] refers to the name of that step. If it is not called GetFolders, then you need to adjust either the step name or the reference. –

Also, I note that when I copy your code, the single quotes are fancy quotes with different symbols for opening and closing quote.

body(‘GetFolders’)?[‘value’] 

Have you copied and pasted the code from the web site? If so, delete the single quotes and put in straight single quotes from your keyboard. Some web site editing software changes straight quotes to fancy quotes that are invalid for formulas.

1
  • If that resolved your issue, please mark the answer as described in the tour. If it didn't, please leave a comment, so I can follow up.
    – teylyn
    Oct 27, 2021 at 20:30
0

Please ensure the following points:

1.Rename the first "Send an HTTP request to SharePoint" action to "GetFolders"

2.Make sure that the brackets (), single quotes '' and semicolons ; are English characters.

Uri:

_api/web/GetFolderByServerRelativeUrl('/sites/YourSiteName/YourDocumentLibraryName')/Folders

Headers Key: accept

Headers Value: application/json;odata=nometadata

enter image description here

3.On the Filter array action, enter the following expression in the Form field. Of course, you should also pay attention to the input of English characters

Form:

body('GetFolders')['Value']

Experssion:

@and(equals(item()?['ItemCount'], 0), not(equals(item()['Name'], 'Forms')))

enter image description here

4.On the second "Send an HTTP request to SharePoint" action, please enter the below api to the Uri field.

_api/web/GetFolderByServerRelativeUrl('/sites/YourSiteName/YourDocumentLibraryName/ExpressionGoesHere')

For the ExpressionGoesHere part in the Uri, use the expression items('ForEach_Folder')['Name']

enter image description here

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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