Reputation: 8616
Sitecore workbox does not create a new version hence it does not track the change set. (Workbox being used by staff people, admin needs to track these changes.) According to what I have noticed, When the item is not in the final workflow state, Sitecore allows to override the content, but if the item is in the final workflow state, it will create a new version, which tracks all these changes.
Is it possible to create a new version for non final workflow states? Is it a good idea? Why Sitecore does not do this by default?
Upvotes: 0
Views: 292
Reputation: 2782
The behavior you described is what documentation says. New version of item is created only when item is in final workflow state and
The next time a content author clicks Edit for this item to lock it before making changes, Sitecore automatically creates a new version of the item and places the new version in the Draft state, while the first version remains published.
There is also important information:
Make sure that content authors or other workflow users don't have a Sitecore administrator account. Otherwise, the workflow will behave differently. For more information about why the workflow behavior is different for a Sitecore administrator, see the section Using a Workflow.
According to workflow reference documentation you can use __OnSave command to create new version of item when a user saves changes to an item.
Use the /sitecore/templates/System/Workflow/Action template to create custom action.
Create a class that implement your desired behavior.
namespace OnAction
{
public class WorkflowAction
{
public void Process(WorkflowPipelineArgs args)
{
}
}
}
Here is example of creating new item version:
var language = Sitecore.Globalization.Language.Parse("en");
var item = master.GetItem(itemPath, language);
using (new Sitecore.SecurityModel.SecurityDisabler())
{
try
{
item .Versions.AddVersion();
item .Editing.BeginEdit();
....
item .Editing.EndEdit();
item .Editing.AcceptChanges();
}
catch (Exception ex)
{
item .Editing.CancelEdit();
}
}
More information about creating custom action here. Link to workflow reference.
Upvotes: 2