cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Apaco89
Level: Powered On

Deleting an item from SharePoint Documnet Library

Hello, 

 

I am trying to delete an item from the SharePoint Doucment library using Flow. 

 

We have a sharePoint list with employee informations and a doucment library with pdf files associated with each employee.  We have , user id column in the document library against each pdf file. 

 

We want to delet the pdf file associcatedwith a employee if he/she leaves the company.  for that , I am creating a flow and checking the user last day column and compare it with today, if its greate than today , i will set the status as " Not in Company". 

 

Now, I want to delete the associated file from the doucment library, How can i do that? I was trying to do this by checking the id column in the List and the userId column from the document library but, I dont know how to get the column name from the document library since I am getting the info(GetItem) from the list in the previous step.

 

Capture.PNG

Can anyone please help me to do this? Plesae let me knwo if you need more info. 

 

Thanks, 

Apaco

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Deleting an item from SharePoint Documnet Library

Hi @Apaco89

Do you want to delete file from the SharePoint library if the user leaves company?

According to your description, I have made a SharePoint list which contains columns ID, Title, LastDay, Status. And a library contains columns Name, UserId.

Note: UserId is of type Number which has same value with ID from the list.

Trigger the flow with a manual button.

Get items from the list. Add a condition to filter out items that LastDay are less than Today’s date, input the following code:

@less(items('Apply_to_each')?['LastDay'], utcnow('yyyy-MM-dd'))

Then Update the Status to Not in company of corresponding item.

Then get files (properties only) to get the specific file using Filter Query with the following code:

UserId eq ‘ID’

Then add the action Delete file to delete the specific file from library.

Images for your reference.

1.PNG2.PNG3.PNG

 

Best regards,

Mabel

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Community Support Team
Community Support Team

Re: Deleting an item from SharePoint Documnet Library

Hi @Apaco89

Do you want to delete file from the SharePoint library if the user leaves company?

According to your description, I have made a SharePoint list which contains columns ID, Title, LastDay, Status. And a library contains columns Name, UserId.

Note: UserId is of type Number which has same value with ID from the list.

Trigger the flow with a manual button.

Get items from the list. Add a condition to filter out items that LastDay are less than Today’s date, input the following code:

@less(items('Apply_to_each')?['LastDay'], utcnow('yyyy-MM-dd'))

Then Update the Status to Not in company of corresponding item.

Then get files (properties only) to get the specific file using Filter Query with the following code:

UserId eq ‘ID’

Then add the action Delete file to delete the specific file from library.

Images for your reference.

1.PNG2.PNG3.PNG

 

Best regards,

Mabel

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Apaco89
Level: Powered On

Re: Deleting an item from SharePoint Documnet Library

Thank you !  It worked

Helpful resources

Announcements
firstImage

New Ranks and Rank Icons in April

Read the announcement for more information!

firstImage

Better Together Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Kudoed Authors
Users online (5,129)