I've changed the Element Root Name of my Schemas and now I want to synchronize my components with their new Root elements.

I'm trying to do it with the CoreService.SynchronizeWithSchemaAndUpdate method. Defining Flags like this:

SynchronizeOptions options = new SynchronizeOptions();
options.SynchronizeFlags = Tridion.ContentManager.CoreService.Client.SynchronizeFlags.FixNamespace;
options.SynchronizeFlags = Tridion.ContentManager.CoreService.Client.SynchronizeFlags.RemoveUnknownFields;
options.SynchronizeFlags = Tridion.ContentManager.CoreService.Client.SynchronizeFlags.ApplyDefaultValuesForMissingMandatoryFields;

And calling:

CoreService.SynchronizeWithSchemaAndUpdate(comp.Id, options);

But it crash giving me this exception:

Unexpected root element: Content. Expected:uuid:fe3b0600-5bfd-4224-b9ef-63c99bbb854e:MiceHPContent.

In this case, old Element Root Name was "Content" and I've changed it for "MiceHPContent". The SynchronizeFlags.FixNamespace flag it shouldn't to fix this problem precisely?

Here its defininiton from http://docs.sdl.com/LiveContent/content/en-US/SDL%20Tridion%20full%20documentation-v1/GUID-9E83FE0C-F650-451F-BEB3-7960A4925D90#docid=GUID-2B44D2F8-65E9-40DD-8408-DF1537BE50F5&filename=GUID-2B44D2F8-65E9-40DD-8408-DF1537BE50F5.xml&query=&scope=&tid=&resource=&inner_id=&addHistory=true&toc=false&eventType=lcContent.loadDocGUID-2B44D2F8-65E9-40DD-8408-DF1537BE50F5:

If the namespace of the content item's root element is not the same as the Schema's, it is set to the Schema's.

How can I synchronize the components?

Thank you.

  • I'm not sure a root node name change is covered by synchronizing the namespaces. If you open these Components in the GUI, do the fields disappear? You might need to copy fields using the Core Service instead (maybe from the XML). – Alvin Reyes Apr 21 '15 at 4:27
  • If I open a component in the GUI, i can save it and it works correctly changing and synchronizing the fields and namespace but i have more than 50000 comps, I can't do it manually and in the description of the flag it seems that could resolve my problem. Thanks for response. – Arnau Apr 21 '15 at 8:54
  • Not sure what's wrong, but there's another method, SynchronizeWithSchema, that might work. This takes an IdentifiableObjectData object instead of an ID and doesn't save the changes. – Alvin Reyes Jul 9 '15 at 16:53

You are not adding the flags together (using |= for instance), but rather overriding it every time.

Try it like this:

options.SynchronizeFlags = FixNamespace | RemoveUnknownFields | ApplyDefaultValuesForMissingMandatoryFields;
| improve this answer | |
  • You are right, but it's still crashing with your fix. Also I have tryed with flag SynchronizeFlag.All, that include all options, and the errors are always the same. It seems that this method not work correctly. – Arnau Apr 20 '15 at 14:27
  • Hi Arnau, what version of Tridion are you using, 2013, 2013 SP1 or 2013 SP1 HR1? – Elena Serghie Apr 20 '15 at 17:10
  • Hi Elena, I'm using 2013 SP1 HR1 – Arnau Apr 21 '15 at 7:32
  • It's possible that this method cannot fix the root element name for you (but it can fix other things like the namespace and missing fields). I guess you'll need to do a Where Used and update the root element name for all of the Components yourself. – Peter Kjaer Apr 21 '15 at 8:54

If all you've done is change the root element name, then you could fix them with a fairly simple XSLT, or by loading the XML into your favourite kind of DOM object and manipulating the nodes. A simple core service script would suffice for the task.

To be honest, it sounds like you're tackling it in the wrong order. There's no need to change the schemas before you've figured out how to update the content.

| improve this answer | |

A late answer, but there is now an Alchemy tool to automate this process: https://www.alchemywebstore.com/plugins/Component-Synchronizer

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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