none
Update SharePoint 2013 workflow without stopping running instances (VisualStudio 2012)?

Answers

  • Hi,

    I've not tried it yet but maybe this is how it might work:

    Let's say you have a workflow running and let's call it version 1 and now you want to change it and deploy as version 2.

    • Change your workflow properties (elements.xml) to host it in different location by changing the module's url to new place 'wfsvc/new-guid'. This will deploy your workflow as the same name (but maybe you want to change the workflow name also adding version, if needed) as a new place without affecting your existing workflow. You can also add a custom workflow properties in the elements.xml file like 'MyWFVersion' to keep track of the workflow version and access it programmatically.
    • Now to ensure that version 1 is not used anymore, you need to deprecate the version 1 of the workflow. You can do so by using code like below:
      WorkflowServicesManager.Current.GetWorkflowDeploymentService().DeprecateDefinition(definitionId)
      You can activate the code in feature receiver

    Now user will see the same workflow (if you don't modify the title) but basically it's updated one. And since you have deprecated the version 1, it'll not be shown in the ui, but internally running workflow will continue running. I've done workflow deployment few months ago and client is asking for changes in workflow and I'm going to see how you fix the problem :-)


    Thanks,
    Sohel Rana
    http://ranaictiu-technicalblog.blogspot.com



    Thursday, September 19, 2013 6:24 AM

All replies

  • Hi,

    I've not tried it yet but maybe this is how it might work:

    Let's say you have a workflow running and let's call it version 1 and now you want to change it and deploy as version 2.

    • Change your workflow properties (elements.xml) to host it in different location by changing the module's url to new place 'wfsvc/new-guid'. This will deploy your workflow as the same name (but maybe you want to change the workflow name also adding version, if needed) as a new place without affecting your existing workflow. You can also add a custom workflow properties in the elements.xml file like 'MyWFVersion' to keep track of the workflow version and access it programmatically.
    • Now to ensure that version 1 is not used anymore, you need to deprecate the version 1 of the workflow. You can do so by using code like below:
      WorkflowServicesManager.Current.GetWorkflowDeploymentService().DeprecateDefinition(definitionId)
      You can activate the code in feature receiver

    Now user will see the same workflow (if you don't modify the title) but basically it's updated one. And since you have deprecated the version 1, it'll not be shown in the ui, but internally running workflow will continue running. I've done workflow deployment few months ago and client is asking for changes in workflow and I'm going to see how you fix the problem :-)


    Thanks,
    Sohel Rana
    http://ranaictiu-technicalblog.blogspot.com



    Thursday, September 19, 2013 6:24 AM
  • Hi Sohel,

    Thank you for your reply. 

    I've been able to post a new version of an existing workflow without interfering with existing workflows, so the first part of the answer seems to be working. I just have to make a checklist of the steps to manually change the necessary parts of the xml files. 

    Also note that I have to change the name of the solution, the feature composition and the workflow in order to achieve version numbering on all parts of the solution. 

    However, the second part of your answer does not apply to my problem. Since the workflow should be able to be deployed to SharePoint Online, I cannot use code. And since the workflow is built on top of SharePoint 2013 Visual Studio template, there is no possibility to use C# coding. I can - of course - achieve this by manually setting the properties of the old workflow to NOT to start when new items are created. 

    I marked your answer as a solution to my problem, since the first part gives a working solution to my problem. 

    Thank you,

    Sören

    Monday, September 30, 2013 8:59 AM