Sitecore Workflow Is Not Working

大憨熊 提交于 2019-12-01 00:36:26
Jay

I used Powershell Script and it looks like this. It updates the empty field and perfectly works.

##################################################################
##  1. Set default workflow state in template's standard value  ##
##  2. Before running script, must set correct Context Item     ##
##################################################################

function SetWorkflow($item)
{
    ## Update only items assigned __Default workflow
    if ($item."__Default workflow" -eq "{A5BC37E7-ED96-4C1E-8590-A26E64DB55EA}") {
        $item.__Workflow = "{A5BC37E7-ED96-4C1E-8590-A26E64DB55EA}";
        $item."__Workflow state" = "{190B1C84-F1BE-47ED-AA41-F42193D9C8FC}";
    }
}

## Update correct workflow information.
get-item . -Language * | foreach-object { SetWorkFlow($_) }
get-childitem . -recurse -Language * | foreach-object { SetWorkFlow($_) }

## Show Updated Result
get-item . -Language * | Format-Table Id, Name, Language, __Workflow, "__Workflow state", "__Default workflow"
get-childitem . -recurse -Language * | Format-Table Id, Name, Language, __Workflow, "__Workflow state", "__Default workflow"

When you set the default workflow value on a standard values item it does not automatically and go through and add existing item versions into a specific workflow state. This is because any content that was previously published would become unpublished as it would go to the default state of the workflow, which is typically a draft state.

The next time you add a version to the item that now has workflow (either explicitly or by "editing" as a lower level user), its state should be set to draft as you'd expect.

If you need to migrate existing versions of items into workflow at particular state you will probably need to do this via code.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!