cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
joe904
Helper II
Helper II

Flow Assistance: When an item is deleted

Hey Guys,

 

I am working on a flow that when an item is deleted from a SharePoint List that it notifies me using email, and at the same time it takes the item details and moves them to another SharePoint List of where I will keep these deleted items. I have tried using the Get Items connector but it seems to focus more on the adding of items. Any help is much appreciated....

 

5 REPLIES 5
Pstork1
Dual Super User
Dual Super User

I'm not sure this is going to be possible.  The problem is that the item is already in the Recycle Bin by the time the flow triggers, so there is no way to get the actual details of the item that was deleted.  There are HTTP REST calls that can do that, but I can't find a way to use them without the GUID of the object in the recycle bin and that isn't provided by the delete trigger.

 

So you can definately use a trigger on deleted items to send an eamil, but there is no way to get anything except the basic properties.  You also need to be a site collection admin for that to work.  Otherwise those properties will also be blank.



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

@joe904 

I agree with the comments provided by @Pstork1 but would like to suggest another approach.  You can create a custom permission level in SharePoint that allows your users to create/edit items but not delete them.  If you go this route, add check box (yes/no) column to the list titled "Delete this item".  When the item is saved and the Delete box is checked, your Flow can copy the data over to the archive list and then delete the existing item.

If you need help with this, please post here.

 

 

 

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

Scott

Thanks for the input @Pstork1 and @ScottShearer.

That is a really good idea @ScottShearer. I do not think I could use the Yes/No since it seems the functionality is more for a form. I am directly using the list to add (New) and delete. When I added the column, the Yes/No did not show up in the list view. I was searching online and found this posting of creating a column and then adding some JSON code into the column. It is basically a clickable link that connects to my workflow using the workflow's ID.  It works fine, it calls my workflow with no issues, but maybe it is my lack of expertise with JSON and workflow, but I keep getting an error in my workflow. I have a simple Manual Trigger with a Send email action. I keep getting this error. I appreciate your continuing assistance.

 image3.jpg

 

image1.jpg

Here is the JSON that I used. 

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "span",
  "style": {
    "color": "#0078d7"
  },
  "children": [
    {
      "elmType": "span",
      "attributes": {
        "iconName": "Flow"
      }
    },
    {
      "elmType": "button",
      "style": {
        "border": "none",
        "background-color": "transparent",
        "color": "#0078d7",
        "cursor": "pointer"
      },
      "txtContent": "Click Here To Delete",
      "customRowAction": {
        "action": "executeFlow",
        "actionParams": "{\"id\": \"2a330326-7d33-4dde-b956-af26e57906ba\"}"
      }
    }
  ]
}

 

 

Pakocha
New Member

You can add a new column to the item line wich is called "Delete", this new column can have two value (yes/no), and the first value is always no. When the user would like to delete, he must to change this column to yes, and so, you have all the details of the item, because the file is not delete. Then you can use the details, and when you finish the flow can delete the item.

 

easy and work¡

jebalert
Microsoft
Microsoft

Here is what I recommend doing. Control the deletion of the object using a Power Apps gallery. Next to the records, create a Remove/Delete button. 

 

Example

  • List1 contains all your data
  • List2 contains log of deleted data and possibly some "After deletion" tasks

 

Using the remove button; target the OnSelect property of the button, leverage a Patch function like this:

 

Patch(List2, Defaults(List2), {FirstName: ThisItem.FirstName}, {Lastname: ThisItem.Lastname}, {EmailAddress: ThisItem.EmailAddress } );

 

 

Then follow up with the removal on the same button property

 

Remove(List1,ThisItem);

 

 

From there you could do whatever you need via Power Automate and the "When an Item is Deleted" trigger.

 

This fulfills the requirement of moving the data over to another list just before deletion.

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (3,492)