locked
Delete a item using workflow RRS feed

  • Question

  • Hi,

    I want to runa workflow for a item in the list when anyone deletes it using the delete action provided by Sharepoint.

    I used the action step for delete item and added my workflow as the second step but it does not give me the desired result

    Can anyone help

    Wednesday, February 9, 2011 3:24 PM

Answers

  • You cannot use SPD workflows to run when an item is deleted from a list/library.  I think you will need to write an event handler.

    Ed

    Wednesday, February 9, 2011 3:39 PM
  • There is a workaround for it to create a sharepoint designer workflow to delete an item, but I personally think it's more work than it's worth.  In a nutshell you disable the delete from the dropdown using javascript in a hidden content editor webpart of the list that you want to trigger the deletion.  Then you add a column to that list called "Delete".  You create a workflow (set it to only be manually started) on that list called "Delete Item".  In that workflow you will add 2 actions:  the first action is to delete the item in the other list.  The second action is to delete the current item in the current list. 

    THEN you need to create another workflow (set to start when new item is created) on that same list that you add two actions.  The first would be to build a dynamic string; in that dynamic string you need to paste the url to the Delete Item workflow start page.  Then you need to remove the ID from that url and replace it with a lookup to the ID of the current item.  The second action would be to update the Delete column with this dynamic string (Workflow Data; Variable1).

    The end user when then click the "Delete" link you created, be taken to the workflow start page, and then they would need to click Start.

    There is a really good link with step-by-step instructions on how to complete this.  I don't have it with me right now but I will see if I have it tomorrow if this sounds of interest to you.

    Thursday, February 10, 2011 1:35 AM

All replies

  • You cannot use SPD workflows to run when an item is deleted from a list/library.  I think you will need to write an event handler.

    Ed

    Wednesday, February 9, 2011 3:39 PM
  • There is a workaround for it to create a sharepoint designer workflow to delete an item, but I personally think it's more work than it's worth.  In a nutshell you disable the delete from the dropdown using javascript in a hidden content editor webpart of the list that you want to trigger the deletion.  Then you add a column to that list called "Delete".  You create a workflow (set it to only be manually started) on that list called "Delete Item".  In that workflow you will add 2 actions:  the first action is to delete the item in the other list.  The second action is to delete the current item in the current list. 

    THEN you need to create another workflow (set to start when new item is created) on that same list that you add two actions.  The first would be to build a dynamic string; in that dynamic string you need to paste the url to the Delete Item workflow start page.  Then you need to remove the ID from that url and replace it with a lookup to the ID of the current item.  The second action would be to update the Delete column with this dynamic string (Workflow Data; Variable1).

    The end user when then click the "Delete" link you created, be taken to the workflow start page, and then they would need to click Start.

    There is a really good link with step-by-step instructions on how to complete this.  I don't have it with me right now but I will see if I have it tomorrow if this sounds of interest to you.

    Thursday, February 10, 2011 1:35 AM