locked
Deleting an item fro a list using a workflow RRS feed

  • Question

  • Hi

    I would like to set up a workflow that deletes records from a list based on a record being deleted from the list the workflow is attached to. In Sharepoint Designer, I see there is a delete item option in 'Actions', however, what would you put in 'Conditions' to determine that a record has been deleted?

    Paul

     

    Wednesday, October 5, 2011 4:20 PM

Answers

  • Hi Paul,

    From your description, I understand that there are some records in another list that related with one record in the list, you want to delete the record in the list, and delete the related records at the same time, if I have any misunderstanding, please feel free to let me know.

    If so, I have a workaround here, you may have a try.

    For example, I have two lists, list1: column a, list2: column aa look up a from list1, delete list1 record, and delete list2 records that has aa equals a in list1.
    1. Create a column in list2, named point: checkbox, default to No,( when update to Yes, the record will be deleted), create a column in list1, named listID: num, (when one related record deleted, the value will be updated to the id of the record)

    2. Create a workflow attach to list1, automatically start this workflow whenever an item is changed:
    condition: if list2:aa equals list1:a
    Action: update item in list2, (set point to Yes)
    condition:
    Action: delete item in list1

    3. Create a workflow attach to list2, automatically start this workflow whenever an item is changed:
    condition: if point equals Yes
    action: update item in list1 (set the listID to the ID of current item)
                    then delete item in list2

    This will achieve loop through list2, delete all records in list2 that related with the record in list1, then delete the record in list1.

    Note: please login with user not System Account, when using System Account, the workflow will not be fired automatically.

    Here is an article about “looping through items in a SharePoint List with SharePoint Designer Workflows”, you can refer to it for more information:
    http://sharepointsolutions.blogspot.com/2008/05/looping-through-items-in-sharepoint.html

    Thanks,
    Qiao

    Friday, October 7, 2011 6:49 AM
    Moderator

All replies

  • Hi Paul,

    From your description, I understand that there are some records in another list that related with one record in the list, you want to delete the record in the list, and delete the related records at the same time, if I have any misunderstanding, please feel free to let me know.

    If so, I have a workaround here, you may have a try.

    For example, I have two lists, list1: column a, list2: column aa look up a from list1, delete list1 record, and delete list2 records that has aa equals a in list1.
    1. Create a column in list2, named point: checkbox, default to No,( when update to Yes, the record will be deleted), create a column in list1, named listID: num, (when one related record deleted, the value will be updated to the id of the record)

    2. Create a workflow attach to list1, automatically start this workflow whenever an item is changed:
    condition: if list2:aa equals list1:a
    Action: update item in list2, (set point to Yes)
    condition:
    Action: delete item in list1

    3. Create a workflow attach to list2, automatically start this workflow whenever an item is changed:
    condition: if point equals Yes
    action: update item in list1 (set the listID to the ID of current item)
                    then delete item in list2

    This will achieve loop through list2, delete all records in list2 that related with the record in list1, then delete the record in list1.

    Note: please login with user not System Account, when using System Account, the workflow will not be fired automatically.

    Here is an article about “looping through items in a SharePoint List with SharePoint Designer Workflows”, you can refer to it for more information:
    http://sharepointsolutions.blogspot.com/2008/05/looping-through-items-in-sharepoint.html

    Thanks,
    Qiao

    Friday, October 7, 2011 6:49 AM
    Moderator
  • Thanks Qiao, I think that will do.

    Paul

     

    Monday, October 17, 2011 6:55 PM