locked
Problem with deleting Workitem. RRS feed

  • Question

  • I have a method which should remove workitems.

     public static void DeleteTask(string taskName)
            {
                using (var wm = Client.OpenWorkItemManager())
                {
                    if (wm.ListWorkItems().Any(w => w.Name == taskName)) wm.DeleteWorkItem(taskName);
                }
            }

    I get an exeption on string

     wm.DeleteWorkItem(taskName)

    {"The remote server returned an error: (409) Conflict."}

    The specified workitem has been marked for deletion and is being reclaimed.

    However, this method is called once as this workitem may be marked for deletion before?

    Sunday, February 1, 2015 5:29 PM

Answers

  • Unlike a workitem, task doesn't have a transient state called "Deleting". Task will be deleted when "Delete Task" call is return from server.
    Wednesday, February 4, 2015 6:52 PM

All replies

  • It looks like you have already issued a deletion for that work item.  Once you delete a work item it moves to "Deleting" state, and after some time (usually it's on the order of a few seconds) it will be deleted and disappear from all queries, etc.

    At that point, you can recreate a work item with the same name (if so desired).

    Can you check to see if this work item is still in deleting state?  Are you still seeing this issue?  Generally speaking it is expected that if you delete a work item twice the second delete may hit this failure.

    -Matt

    Monday, February 2, 2015 7:07 PM
  • After reading your responses to questions from other developers, I decided to add tasks to the work, rather than new workitems for each task. But TaskState enum does not contain "deleting", how can I check whether the task is not removed at the moment?
    Wednesday, February 4, 2015 12:08 PM
  • Unlike a workitem, task doesn't have a transient state called "Deleting". Task will be deleted when "Delete Task" call is return from server.
    Wednesday, February 4, 2015 6:52 PM