1

I have a tenant with a site. When I clone the existing site, the script does not clone the media library or themes. Instead the new site points back to the original sites media and theme locations. (configured on the site node itself).

I have created a new Tenant from scratch and created a dummy site, and cloned that. That clone works as expected - media library and themes are clones and the links updated to those locations.

I'm am trying to retrospectively fix the problem tenant, but I can't see what is wrong. Is there a known scenario where this situation would occur ? Is there something specific I can check?

The tenant configuration appears correct, as does the site node.

1
  • 1
    The "rewriting" of references to their respective new locations in the cloned tree is a background process that starts after the cloning. If that fails, for whatever reason. there is no other way to fix it than to cook up maybe an SPE script to fix it. Jan 29, 2021 at 10:03

1 Answer 1

1

This turned out to be a field name collision when the clone script was updating ID based links in the cloned site - it looks in all fields on all items, when it finds an ID it checks the path and updates the ID to the equivalent item in the site just cloned.

The scriban template in Sitecore uses a field name of 'Template' to store the scriban data. During the clone operation the script was finding an ID within the scriban and attempting to update it. The script uses a name-based field reference when it updates the field using the PSE auto-properties for this assignment.

$currentItem."$($field.Name)" = $updatedFieldValue

This then failed as it was interpreted as trying to update the item (sitecore) template id, rather than the multi-line text field with the name "Template". This would throw the following exception and bail out of the clone process.

ManagedPoolThread #11 17:36:30 ERROR 'Template' is a ReadOnly property.

Updating the assignment to use an ID based field reference for the assignment resolves the issue:

$item.Editing.BeginEdit()
$currentItem.Fields[$field.ID].Value = $updatedFieldValue
$item.Editing.EndEdit()

Thanks to Michael West for the assistance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.