2

I am trying to synchronize Components on a Schema that has a multi-value optional field "AAA" of type Embedded Schema "Aaa", which has a mandatory embedded text field "BBB" and another optional embedded field "CCC".

AAA - optional multi-value field on Embedded Schema 'Aaa'
 +-> BBB - mandatory single-value text field
 +-> CCC - optional single-value text field

When I create Components on my Schema, I don't have to enter any value for field AAA, and nothing appears in the Component XML. When I save the same Component in the CME, it saves successfully.

I have a Core Service client that executes Client.SynchronizeWithSchemaAndUpdate(tcmUri, SynchronizeOptions), where Client is an ICoreService object using basicHttp binding, tcmUri is the TCMURI of the Component and SynchronizeOptions is new SynchronizeOptions { SynchronizeFlags = SynchronizeFlags.All };

The code above yields a FaultException<CoreServiceFault> whose message reads:

{"XML validation error. Reason: The element 'AAA' in namespace 'Aaa' has incomplete
content. List of possible elements expected: 'BBB' in namespace 'Aaa'."}

It doesn't make sense why I receive this error. Field AAA is optional multi-value. Only embedded field BBB is mandatory and this error should only be thrown if optional embedded field CCC has a value and mandatory field BBB has been omitted.

So my questions are: what is going on? is this a bug? has anybody seen this error before?

3

Unfortunately some of the flags are "destructive", meaning they can turn perfectly valid XML into invalid XML. The following flags should be safe:

SynchronizeFlags.ApplyDefaultValuesForMissingMandatoryFields |
SynchronizeFlags.Basic |
SynchronizeFlags.ConvertFieldType |
SynchronizeFlags.FixNamespace |
SynchronizeFlags.RemoveAdditionalValues |
SynchronizeFlags.RemoveUnknownFields;

The following flags can convert valid xml into invalid xml:

SynchronizeFlags.ApplyDefaultValuesForMissingNonMandatoryFields
SynchronizeFlags.ApplyFilterXsltToXhtmlFields

Hopefully we will get a less suicidal alternative to using "All" in a future releases, but it did unfortunately not make it into the SDL Web 8 release.

  • Indeed it works. There is no exception thrown when SynchronizeFlags.ApplyDefaultValuesForMissingNonMandatoryFields is missing. Thanks for the explanation! – Mihai Cădariu Jan 5 '16 at 18:31
2

I have tried and tested the above scenario just now and I can see the component synchronization happening successfully. I further tried couple of more scenarios in the embedded schema and schema fields and all seems to be working fine. So to answer your question - This is not a bug in the API.

Just to get more knowledge, can you double check or may be triple check, you are passing the SynchronizeFlags.All flag while synchronizing. Also, is there anything else in the log apart from the above error?

  • I tried my code in 3 different systems and I have the error in all of them. There seems to be a workaround for it -- not using SynchronizeFlags.All, and instead using all other flags with a bitwise OR between them, except the SynchronizeFlags.ApplyDefaultValuesForMissingNonMandatoryFields. That is the only solution for me at the moment. The moment I add SynchronizeFlags.ApplyDefaultValuesForMissingNonMandatoryFields, the exception is thrown. – Mihai Cădariu Jan 5 '16 at 6:24
  • that's quite weird – Pankaj Gaur Jan 5 '16 at 6:47
  • I haven't double-checked it myself, but SF.All ^ SF.ApplyDefaultValuesForMissingNonMandatoryFields should give the same result as bitwise OR-ing all other flags. – Rick Pannekoek Jan 5 '16 at 19:14

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.