Workflow Templates - Cancel Workflow option RRS feed

  • Question

  • I'm creating a workflow template and want to add the 'Cancel Workflow' option to the Workflow status page for cancelling a workflow that is in progress, by default only 'Terminate Workflow' option is available. Any clue?
    Friday, February 13, 2009 2:12 PM

All replies

  • Hi,

      You can use the if else condition to terminate the wf by dragging the Terminate event

    Saturday, February 14, 2009 9:19 AM
  • Hi Goud,

    Thanks for your answer.

    Terminate workflow causes all the associated tasks get removed, I don't want that, I need to provide the user the ability to 'Cancel Workflow' in the Workflow status page since I want to keep all the tasks that were generated and execute additional logic.

    Btw, I don't see 'Terminate event' option for dragging, how can I add it directly in code?

    Saturday, February 14, 2009 3:36 PM
  • For this scinareo, You can suspend the workflow and move the all task item to other doc library by using Copy method.After that u can resume the workflow from that doc library.Suspend event is there in toolbox.So in status field of task edit form add an item Suspend and handle the suspend event while selecting the Suspend.SAme time u move the list items to other library  for retaining that. 

    Sunday, February 15, 2009 10:20 AM
  • Hi Goud, thanks again for you answer, but my question is: Is it possible when defining a new workflow template to set it supports cancellation for displaying to the user in the workflow status page the 'Cancel workflow now' option?  Based on the microsoft documentation the out of the box workflow templates of MOSS 2007 support that and I want the same for my new workflow template.
    Monday, February 16, 2009 12:24 PM
  • I supposed you can replace wrkstat.aspx which is the status page with your own custom page, other ways include putting 'cancel' button in workflow itself or create a menu item.
    Monday, February 16, 2009 12:55 PM
  • Thanks Frank for your answer. Do you have any example of how to do what you mention? Also, Isn't possible to do it without creating my own custom page? I thought there is a property/attribute of the workflow template that defines if it supports cancellation or not and it automatically add that option in out of the box wrkstat.aspx page.

    Btw, based on MS documentation that option is available in the worklow templates that comes with  MOSS 2007, is it possible to get the wrkstat.aspx page they are using?
    Monday, February 16, 2009 1:02 PM
  • There may be some confusions in MS documentation as 'cancel' and 'terminate' are used interchangebly, see


    In wrkstat.aspx, it also refers to 'if (allowcancellation)' when it means 'termination' - ie. tasks are deleted.

    Do you have the MS documentation that mentions about the ability to really 'cancel'?
    Monday, February 16, 2009 1:13 PM
  • Hi Frank, I don't remember the url of the MS documentation, I'm sure it is an MSDN page, it talks about differences between cancel and terminate a workflow, saying cancel option is available for the MOSS 2007 out of the box worfklow templates, displayed in the workflow status page, and when cancelling a workflow tasks are not deleted. That is the reason I want to use that option, I don't want to loss the tasks, and want to keep them, I just want to provide the ability to an admin user to cancel the workflow and catch that event from code for executing additional logic.
    Monday, February 16, 2009 1:49 PM
  •  This link talks about a lot of things, including canceling a workflow:


    It also points to another link that is supposed to show how to configure the cancellation handler:


    However, going to that link finds nothing.

    I shall continue to figure it out.
    Monday, February 16, 2009 3:55 PM
  • Thanks for your help, ideal scenario is to find the way to display 'Cancel Workflow now' option in out of the box workflow status page, without creating my own page and to be able to catch that event from code.  I have my workflow template in a working condition, just trying to find a 'good' solution for the situation where a workflow instance is idle for long time and an admin user cancel it without removing tasks.
    Monday, February 16, 2009 4:10 PM
  • The collectfeedback, signature and approval workflow can do this OOTB, I just haven't figured out how it is done yet. You can also take a look into those WFs to see if you can spot something.
    Monday, February 16, 2009 6:41 PM
  • Thanks man for your help, I will take a look into those WFs. In case you find something, please let me know.
    Monday, February 16, 2009 6:50 PM
  • Hi Frank,

    Did you find anything?

    Thursday, February 19, 2009 12:49 PM
  • Diego,

    Unfortunately I don't have a ready answer for you. There are two possibilities:

    1. wrkstat.aspx is looking for a variable 'allowcancellation'. If this is set to true, then the 'cancel this workflow' link will appear. However, I cannot find out how this can be set.
    2. Somehow if you program the 'canceleventhandler' it may internally set 'allowcancellation' variable to 'true' and the link will appear.

    There is no documentation that I can find about this. Hope others (especially MSFT) can jump in to help.
    Thursday, February 19, 2009 4:18 PM
  • Thanks Frank for the answer.

    I've tried with 'allowcancellation' variable by changing the out of the box aspx page, but it displays the 'Terminate workflow now' link, not the 'Cancel workflow now' one.

    Do you know if there is any way to contact other MSFT that can help me on this?

    Thanks again.
    Thursday, February 19, 2009 4:57 PM
  • Sorry for the long delay, finally I have something figured out. It is quite a complicated process and unfortunately MS doesn't have any good example, the 'approval workflow' from SDK is still the best bet.

    In short, this is how it can be done:

    1. Create an Infopath form 'CancelationForm', in which you ask the use if he/she wants to cancel.

    2. Add the 'CancelationForm' as a Modification Form and specify the name as 'Cancel workflow' (you will have to know how to do this, though, this is a good example:


    3. The 'Cancel workflow' choice will appear in 'Workflow Status' screen.

    4. Click it and your 'CancelationForm' will show up. Fill out the required information (such as ask user to confirm the cancelation)

    5. Trap the event and write the code to cancel the task and set workflow state to 'Cancelled'.

    Hope this helps a bit. If you haven't done modification form, I advise that you get familiar with it first before tackling this cancelation problem.

    Thursday, March 19, 2009 6:02 PM
  • Thank you very much for the answer! I really appreciate you've spent time helping me on this.

    I'm familiar with association forms, so the concept of implementing a modification form should be very similar. I will follow the steps you've described and hopefully get my cancel feature :)

    Thanks again!

    Thursday, March 19, 2009 6:09 PM