I am currently working on a project that requires me to set up a very simple sitecore workflow. I am running into some difficulties when modifying the existing items to use my new workflow. This is what i did:
The workflow creates a new version when a contentmanager starts editing an item and publishes the item when the submit button is clicked.
I added these workflow items to the standard values of my templates:
The next step would be to set the workflow settings on the already existing items. Luckily we can use sitecore-powershell to do this for us.
function SetWorkflow($item)
{
$item.__Workflow = "{DE29E564-3157-4CAB-81B1-87DF2E983517}";
$item."__Workflow state" = "{27633BF0-B76A-4450-A139-BA53F6943778}";
}
get-childitem . -recurse -Language * | foreach-object { SetWorkFlow($_) }
This script runs without errors.
Now the fun starts: When I opened the items I ran this script on the Workflow and Workflow state properties haven't changed. Weirdly enough, the editor says that the empty values are being inherited from the standard values, though the standard values are not empty, i have set these!
You'd say that the script maybe has failed and that no values have been set. Except when I look the values up in sitecore-powershell, i can see that the values are there.
get-childitem . -recurse -Language * | Format-Table Id, Language, __Workflow, "__Workflow state"
ID Language __Workflow __Workflow state
-- -------- ---------- ----------------
{208D79B1-5B42-4713-A7F9-F2109588F639} en {DE29E564-3157-4CAB-81B1-87DF2E983517} {27633BF0-B76A-4450-A139-BA53F6943778}
{208D79B1-5B42-4713-A7F9-F2109588F639} nl-NL {DE29E564-3157-4CAB-81B1-87DF2E983517} {27633BF0-B76A-4450-A139-BA53F6943778}
{3F3B1132-02DA-4E75-928F-BDB8AED5C3CD} nl-NL {DE29E564-3157-4CAB-81B1-87DF2E983517} {27633BF0-B76A-4450-A139-BA53F6943778}
{8AF23DC5-E7FE-47E3-AC65-AA3D41D81F97} en {DE29E564-3157-4CAB-81B1-87DF2E983517} {27633BF0-B76A-4450-A139-BA53F6943778}
{8AF23DC5-E7FE-47E3-AC65-AA3D41D81F97} nl-NL {DE29E564-3157-4CAB-81B1-87DF2E983517} {27633BF0-B76A-4450-A139-BA53F6943778}
etc.etc.
I tried setting the workflow and workflow state properties on the items by hand. This works kinda, i can go through the workflow once. When a new version is added the workflow and workflow state properties default back to their 'empty' standard values which breaks the workflow for that item.
Does anyone know what's happening here? How can I set the workflow and workflow state properties once and for all?
On the Standard Values of your base template, did you set the workflow on the Workflow
field? It actually needs to be set on the Default workflow
field. The other 3 fields are "current state" fields, i.e. it stores which stage of the workflow the item is currently in, these should be left blank in the your template and standard values.
More info from section 3.3.1 of the Sitecore Workflow Reference:
Assigning Workflows to Items
By default, items are not placed in a workflow when created. Sitecore only places items in a workflow if the “Initial” workflow is set for the corresponding data template standard values item. The Initial workflow corresponds to the Default Workflow field in the Standard Template.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With