I am using below code to create a new component from a existing component. However I am getting metadata exception
ReadOptions _ReadOptions = new ReadOptions() { LoadFlags = LoadFlags.Expanded };
ComponentData OriginalComponentData =
(ComponentData)_CoreServiceClient.Read(ComponentID, _ReadOptions);
ComponentData NewComponent = new ComponentData();
NewComponent.Title = "new-" + OriginalComponentData.Title;
NewComponent.Content = OriginalComponentData.Content;
NewComponent.Metadata = OriginalComponentData.Metadata;
... few more lines of code to set location info and call to create method.
I am getting below error:
XML validation error. Reason: The element 'Metadata' in namespace
'http://www.mycompany.com/tridion/schema/feedback' has invalid child element
'embedded_workflow' in namespace
'http://www.mycompany.com/tridion/schema/feedback'.
List of possible elements expected: 'embedded_global' in namespace
'http://www.mycompany.com/tridion/schema/feedback'.
I am unable to find why I am getting this error. When I check the value of OriginalComponentData.Metadata it's having below XML value
<Metadata xmlns="http://www.mycompany.com/tridion/schema/feedback">
<embedded_workflow>
<workflow_release>Non-Release</workflow_release>
<effective_date>2013-01-29T15:35:53</effective_date>
</embedded_workflow>
</Metadata>
So why it's invalid for new component. I am creating the component at the same location of its original component.