Skip to main content

I have a process that is triggered when a user uploads a document to a document library.

I would like to be able to terminate the process if the document is deleted from the library, as otherwise I end up with processes running on documents which no longer exist.

Can anyone tell me how to do this?

An alternate solution may be to prevent users from deleting items from the document library? I'm not sure how I can do this either?

If anyone has any ideas on the best solution for this, I would love to hear them.

Thanks in advance!

You can write a SharePoint event receiver for your list (ItemDeleting event).

There you can read which item will be deleted and delete the process through the k2 api.

marco


Hi Marco,

Thanks very much for getting back to me - this sounds like just the sort of thing that I want to do.

Excuse my ignorance (I haven't done any work with the API), but I imagine that I would have to pass in the process instance ID of the existing process in order to cancel it - any recommendations on the best way to obtain the process id?

Thanks again for your assistance - I really appreciate it!


Although this approach will work, I think it should be possible to do this without writing an event receiver.  Just use a second workflow that only gets fired when an item is deleted that will Finish an asynchronous server event in the first workflow.


Here is an existing thread that talks about IPC events.  I think the same principles could be used in your case.


http://www.k2underground.com/forums/post/23798.aspx


David


Well, you can do it with a workflow or with an event receiver, both should work. Its a question of what you did before and whats easier for you.


And ye, you will need the process id of the process you want to delete. I guess you know it within the item. If its InfoPath you can get to the file (SPListItem.File) and extract the process id from the _K2 node within the xml.


marco


Reply