cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

Create flow that deletes files in document library and sends email which mentions the files which have been deleted

Hi,

 

I have set up a recurrence flow that deletes files uploaded in a SharePoint document library every night. However, I am finding it difficult to enable the flow to send email which lists the files (file name) which has been deleted. Below is my current configuration:
flownzcdquestion.JPG 

In my attempts, for each individual files deleted it sends an email. However, I would like all the files which have been deleted to be listed in one email. Is this possible?

 

Kind Regards,

Iyana

 

9 REPLIES 9
Highlighted
Dual Super User II
Dual Super User II

Re: Create flow that deletes files in document library and sends email which mentions the files which have been deleted

Initialize either a string variable or an array before the loop to delete the files.  Then add the file names to the variable.  That way you'll have a list of deleted files when you want to create the email.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Highlighted
Anonymous
Not applicable

Re: Create flow that deletes files in document library and sends email which mentions the files which have been deleted

@Anonymous hello.

 

You should use LIST FOLDER action. That will bring in the files at once and you can email the same list. instead of using variables.

 

If this helps you, kindly accept as solution and give a kudos so that others can get to the solution easily.

Highlighted
Community Support
Community Support

Re: Create flow that deletes files in document library and sends email which mentions the files which have been deleted

Hi @Anonymous,

 

Has your problem been solved?
If your problem has been solved, You could go ahead and mark the post as solved by clicking “Accept as Solution” so that this thread will be marked for other users to easily identify!

Best Regards,
Community Support Team _ Lin Tu

Highlighted
Anonymous
Not applicable

Re: Create flow that deletes files in document library and sends email which mentions the files which have been deleted

Hi @Pstork1 ,

 

I have tried out your solution, however i had the following warning - The variable action 'Initialize_variable' of type  InitializeVariable cannot be nested in an action of type 'Apply to each'. This warning appeared when I selected Name in the Value field.

flow1.PNG

On a general note, as soon as I select Name or Display Name when initializing variable or creating an email body, Flow would always display the Apply to each container. As a result, it would send me separate emails for each files that exist within the SharePoint list. What I want to achieve is create an email which lists all the deleted files / files within the list, instead of having an email sent for individual files. Is this possible?

 
 
 
Highlighted
Anonymous
Not applicable

Re: Create flow that deletes files in document library and sends email which mentions the files which have been deleted

Hi @Teja_Veleti,

 

I have tried the solution which you had mentioned i.e. using List Order function. However, it still didnt achieve what I had wanted to achieve. Whenever I select Name or DisplayName, the 'Apply to each' container would appear, which sends me individual emails for each files on the list.

flow2.PNG

What I would like to achieve is send an email which lists down all the files within the list which will then be deleted or vice versa. Is this possible?

Highlighted
Anonymous
Not applicable

Re: Create flow that deletes files in document library and sends email which mentions the files which have been deleted

Hi @Pstork1 ,

 

I have implemented your solution, however, it still didnt achieve what I wanted to achieve. It displayed me the warning as in the picture beside:flow1.PNG

 

As a general note, whenever I select displayName or Name when initialising variable or when creating the automated email, the apply to each container would always appear, which leads the flow to send me separate emails for each of the files present within the list. What I wanted to achieve is I would like to send an automated email which lists all the files or all the files within the lists which have been deleted. Is this possible?

Highlighted
Dual Super User II
Dual Super User II

Re: Create flow that deletes files in document library and sends email which mentions the files which have been deleted

You have to initialize the variable outside the loop and then use a Set Variable or Append to Variable action inside the loop.

screenshot.png



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Highlighted
Anonymous
Not applicable

Re: Create flow that deletes files in document library and sends email which mentions the files which have been deleted

Hi @Pstork1 ,

 

Thank you for your help! I am now able to list the file names in one email. Is there a way to separate the file names with a comma, when jotting them down in the email?

Highlighted
Dual Super User II
Dual Super User II

Re: Create flow that deletes files in document library and sends email which mentions the files which have been deleted

if you look closely at the screenshot I posted you will see a semicolon after the dynamic content that appends each name to the variable.  Just change that to a comma and you'll get a comma after each name.  You will of course get one extra one at the end that you'll need to trim off after you exit the loop to be perfect.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
FirstImage

Microsoft Ignite 2020

Check out the announcement of Power Platform content at Microsoft Ignite!

thirdImage

Experience what's new for Power Automate

Join us for an in-depth look at the new Power Automate features and capabilities at the free Microsoft Business Applications Launch Event.

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (10,572)