0
votes

At my work, we use Sitecore 7.2. We have two forms online that turn submissions into items in the sitecore tree. These items need to be reviewed/edited by an editor before being dragged from a "submission" folder into a folder that displays on the live site.

The issue we were originally having is that these items were not part of a workflow. So if an edit was made to them, a publihing job wasn't triggered. I created a simple workflow that any edit/save automatically approves and publishes an item.

I applied it to the standard values field for both template A and template B. When creating new items with template A (whether through the form submission or manually) the item is created and the workflow is attached.

However, with template B, the workflow is never attached. if I manually added the default workflow to the item itself it works fine - but I need it to already be added in when the item is created - or when a new version of the item is created.

Is there any reason why a "Default Workflow" added into the "__Standard Values" of a item template would not be part of items using that template?

http://i.imgur.com/QE5JuyP.png

2

2 Answers

3
votes

This is the same issue I got last time. Some people said it works correctly even we update workflow into existing items, but it doesn't work for some others.

The problem is that even you set the default workflow in standard values, "Workflow" and "State" fields are empty in item's properties. So, what I did is using PowerShell plug-in. If you use this below code, it would work perfectly.

##################################################################
##  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.
## Uncomment below two lines if you are ready to go for updating    
#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"
0
votes

I am facing the same issue. I do not see why my default workflow is not kicking in when locked for Editing or when newly created. If there is no other option then I think I have to go with @Jay's answer.

In addition to the above solution we might also want a check, to see if the Workflow State is Empty, in-order not to override the existing Workflow State (which is set manually).

EDIT: My Scenario: I installed a package with template first, then I installed another package with ONLY the Standard Values with Default Workflow set. I assume this caused the issue.

I re-packaged the template with standard values and Default Workflow set. Re-Installed the package by Overriding the existing templates. Now whenever I create a new Item, workflow is set properly. Hope this helps you.