Keep existing state for all items when changing workflow

I implemented a custom workflow and set it for Document (Page):

  • added in my default profile
  • upgrade step import workflow
  • in portal_workflow/manage_selectWorkflows set it for Document (Page), click on Change, click on Update security settings

It was set and it is working. The problem is my all pages are now in Private state even if the most of them were in Published state before.

I did it in my local application, so it is not a real problem. But how can I set it (in production website) to avoid this issue?

I think maybe it is related to initial_state value:

<dc-workflow workflow_id="foo_publication_workflow" title="Foo Publication Workflow" description="" state_variable="review_state" initial_state="private" manager_bypass="False">

It is indeed. With CMFCore, an object can participate in more than a single workflow. As a consequence, each workflow must have its own state (and other workflow related variables). If you assign a new workflow to an object, the corresponding state is "initial" -- independent from the state in other workflows.

I have seen (in Plone 4) a view which allows you to change an object from one workflow to another and control the corresponding state mapping at least for simple cases. Unfortunately, it was a long time ago -- and I have forgotten the details. But likely, I was guided by the plone control panel to this view.

Should you find nothing (or nothing with the necessary amount of control), you can always write a script which visits all affected objects, determines the state for the object in the new workflow from that in the old one (i.e. map the state appropriately) and then set the state for the new workflow.

1 Like

Great. Thank you.

Alessandro - on StackOverflow:

You have to migrate your existing content with old workflow to the new one.

In the ZMI portal_workflow for the Document type must be specified the OLD workflow.

Then go to the Plone control panel -> Types (@@types-controlpanel) -> choose Document in the drop down menu and then choose the new workflow.

Now you are able to properly configure exact match between old states and the new ones.

Click apply to start migration.