Sitecore – Item cloning

Sitecore lets you clone an item which means that instead of copying an item to a new location, it copies the original item and keeps it’s fields up to date with the source item. Sitecore describes it perfectly as follows:

“A clone is an item that is not just a copy of the original item, but one that inherits the field values from the original item. If you update a field in the original item, the corresponding field in the clone is also updated.”

With the introduction of SXA and the improved focus on reusing content, clones became a more mainstream way to share content. Within SXA it’s called delegated areas, which uses the normal item cloning functionallity for it’s base, and extends it with content-editor warnings.

My learnings on item cloning

When I’ve started using delegated areas / item cloning in SXA, I ran into some “issues”, as I anticipated that an item clone would have all its fields updated, renamed, and deleted. I’ve learned that my assumptions were incorrect and that you’d have to take the following things into account.

  • The workflow on the target item isn’t automatically updated when the source item is updated. Sitecore explicitly states this in the documentation:
    If you clone an item that is in a workflow, the workflow and the Workflow state properties are copied to the clone item. After the workflow fields are copied, the workflow properties of the clone and the workflow properties of the original items are not connected anymore. If you change the workflow state of the original item, the workflow state of the clone does not change.
  • When you delete the source item, the clone item isn’t automatically deleted as well
  • When a new language, version or subitem is added to a source item, it isn’t automatically copied to all the clones.
  • When you change the template of the source item, it isn’t automatically propagated to the clones.
  • When you rename the source item, it isn’t automatically propagated to the clones.

Changes to make it work how i anticipated item cloning would work

All “issues” above except for the automatic item renaming are configurable trough configuration settings out of the box. These settings are:

ItemCloning.InheritWorkflowData
Specify whether you want the workflow and workflow state fields to be inherited by clones from their source item. Note: When you change the setting value, clones move in or out the workflow, which may affect their behavior, for example, on publishing.
Default value: false

ItemCloning.ForceUpdate
Specify whether clones should be updated automatically when:

  • a new version is added to the original item.
  • a new language is added to the original item.
  • a new sub-item is added to the original item.

Note: If true, all the clones of the original item are updated automatically.
Default value: false

ItemCloning.DeleteClonesWithOriginalItem
Specifies whether item clones should be deleted when the original item is deleted. If true, when the original item is deleted all its clones are deleted and not just uncloned.
Default value: false

ItemCloning.ForceUpdate.ChangeTemplate
Specify whether clones should be updated automatically when a different template is selected for the original item. Note: If true, all the clones of the original item are updated automatically.
Default value: false

Additional cloning settings

There are two additional settings that I haven’t used but could be benificial in your situation, these are:

ItemCloning.NonInheritedFields
Specifies a pipe-separated list of field names or field IDs which should be not be inherited by clones from their source item, in addition to the following fields from the standard template that are never be inherited: Updated, Updated by, Revision, Created, Created by, Source, Workflow, Workflow State, Lock

Example: “__Renderings” (or “{F1A1FE9E-A60C-4DDB-A3A0-BB5B29FE732E}”) will exclude the __Renderings field (also known as the Layout field) so that clones do not inherit presentation details from their source items.
Default value: “”

ItemCloning.RelinkClonedSubtree
Indicates that after cloning an item tree structure, all the internal links inside the cloned structure should be re-linked to point to the items in the cloned sub-tree. When the setting value is false, the links in the cloned structure will still link to the items in the original structure.
Default value: false

Leave a Reply

Your email address will not be published. Required fields are marked *