1

I have linked Components in my Component's custom metadata, I want to read tcm uri of them on Content Delivery (WebForms Applciation not DD4T). Here is how Custom_Meta Table in Broker looks like after publishing Component :

enter image description here

I have tried following code using Tridion API for reading Custom Meta but it didn't help: This code gives me only one value of Article (linked Component), is there any way to read multi valued linked Components in metadata?

ComponentMetaFactory metaFactory = new ComponentMetaFactory(publicationId);
IComponentMeta componentMeta = metaFactory.GetMeta("tcm:XX-XXXX-XX");
CustomMeta customMeta = componentMeta.CustomMeta;

StringBuilder meta = new StringBuilder();
foreach (DictionaryEntry de in customMeta.NameValues)
{                  
    meta.AppendFormat("<{0}>{1}</{2}>", de.Key, ((NameValuePair)de.Value).Value, de.Key);
    LogManager.WriteDebugLog("key My key de.Key : " + de.Key + ", value :" + ((NameValuePair)de.Value).Value, "");
}
4
  • Please confirm your application uses (DXA or DD4T) or Web form? Perhaps it's not possible to read that linked component values on the presentation side. But on the CMS side, you can achieve by either TOM.NET or Core services. If you need to achieve this on CD side may be you can publish that linked component Articles as DCP then you can query based on that linked component DCP based on TCM Uri to get those fields data on the linked component.
    – Velmurugan
    Jun 19, 2017 at 14:22
  • My application is using Web Forms, I don't want to read fields of linked component , i just want all linked componnets tcm uri's which are attached in metadata (Bascically whatever in custom_meta table). Linked component Articles are published as DCP. but i need to read them through component, once i have all Linked component tcm uri's i can query them as you suggested Jun 20, 2017 at 6:32
  • Maybe this is relevant and useful: tridion.stackexchange.com/questions/3013/… Jun 20, 2017 at 7:31
  • It seems like it should work but its not working as i don't see any method like getNameValues().get(FIELD_NAME).getMultipleValues() , i have customMeta.NameValues but no further get(string) or getmultiplevalues() method Jun 20, 2017 at 8:15

1 Answer 1

1

It works , i got the solution :)

ComponentPresentation cp = cpf.GetComponentPresentation(uri, templateUri);
        // check if component presentation is published to the broker
        if (cp != null)
        {
            IComponentMeta meta = cmf.GetMeta(uri);
            CustomMeta customMeta = meta.CustomMeta;
             NameValuePair nvp = (NameValuePair)customMeta.NameValues["Articles"];

             int i = 0;
            foreach (var s in nvp.MultipleValues)
            {
                allComponentUris[i] = Convert.ToString(s);
                i++;
            }
        }

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.