3

As the result of importing content with Content Porter 2013, some link fields got their values assigned like this (notice tcccp:unresolved):

<myLinkField
   xmlns:xlink="http://www.w3.org/1999/xlink"
   xlink:type="simple"
   xlink:title="Link Name"
   xlink:href="tcccp:unresolved" />

When trying to access such component with TOM.Net API:

= new ItemFields(component.Content, component.Schema);

the following error occurs:

Invalid URI: tcccp:unresolved. at Tridion.ContentManager.UrlConversion.AddLink(Link link) at Tridion.ContentManager.Session.GetTcmUri(String uri) at Tridion.ContentManager.Session.GetObject(String uri) at Tridion.ContentManager.Session.GetObject(XmlElement linkElement) at Tridion.ContentManager.ContentManagement.Fields.ComponentLinkField.ReadFromElement(XmlElement parentElement) at Tridion.ContentManager.ContentManagement.Fields.ItemFields.InitializeFields(XmlElement schemaFieldsElement, XmlElement contentContainer) at Tridion.ContentManager.ContentManagement.Fields.EmbeddedSchemaField.ReadFromElement(XmlElement parentElement) at Tridion.ContentManager.ContentManagement.Fields.ItemFields.InitializeFields(XmlElement schemaFieldsElement, XmlElement contentContainer) at Tridion.ContentManager.ContentManagement.Fields.ItemFields..ctor(XmlElement rootElement, Schema schema)

Is there any workaround to initialise ItemFields instance, or this is not possible at all?

5

You'll have to load the component as XML, and update/read as XML too. ItemFields will always try to load some of the properties of the linked component when it is initialized, and that means it will fail (as you have noticed already).

tcccp:unresolved means that for some reason the target of that link was not found (or failed to import if it was part of the package) and this was probably logged during the import. Re-doing the import might help here - at least it might help identify which items need fixing.

| improve this answer | |
  • Nuno, now (another) question is how to deal with such situation. Simply c.Content.OwnerDocument.LoadXml(c.Content.OuterXml.Replace("tcccp:unresolved", string.Empty)); doesn't help, because new ItemFields(..) then says: "Operation is not supported on a new item or on a null URI.". Is there any generic value that can be assigned instead? (Otherwise, will need to replace the whole link. – esteewhy Aug 19 '13 at 12:03
  • (Answering myself) Looks like tcm:0-0-0 works, doesn't it? – esteewhy Aug 19 '13 at 12:27
2

tcccp:unresolved is not a valid URI and you cannot use it to read items. tcccp:unresolved is used by Content Porter to flag the link as not resolved.

| 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.