2
votes

I already have an content item (item) with template A. Template A has not set any workflow initially and I set a new workflow in template's standard value.

If I go to the content item's workflow section, there is only "Default workflow" update. The fields "Workflow" and "State" are empty even I set "Initial State" in the workflow's property, as shown below screenshot. So, workflow process is not working on that item.

However, if I create new item with the template already set workflow, I could see all filled workflow fields based on its initial workflow setting. So, workflow process is perfectly working.

I have a number of pages without workflow setting and I'm about to assign new workflow in its templates.

How can I solve this issue???????


enter image description here

2
Did you set the workflow in the Default workflow field on the template itself, or in the Standard Values of the template? Also, are you logged in as Administrator or a "regular" user?jammykam
In the template's standard value, I set only "Default workflow" field and "Workflow" and "State" fields are empty in template's standard value.Jay
Are you logged in as an Administrator?jammykam
From what I understand you want to assign initial step of workflow to already existing items. Am I right? There is a question stackoverflow.com/questions/28945613/… which describes how you can use Sitecore Powershell Extensions to do this.Marek Musielak
It works fine for me. You need to "lock and edit" the item, at that stage it enters the initial workflow stage and the Workflow, State and Lock fields will be updated with the correct values,jammykam

2 Answers

2
votes

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"
1
votes

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.