8

I am trying to grab a multimedia component which is linked as a parameter to a TBB. Typically I am just grabbing strings passed in as parameters such as below, however I am unable to find a way to do the same for components.

String value = package.GetValue("inputValue");

I have tried to get the value from the properties (as shown below), with no luck.

string xsltComponentId = xsltMMComponentItem.Properties[Item.ItemPropertyTcmUri];
Component xsltMMComponent = (Component)engine.GetObject(xsltComponentId);

Also tried to get it AsSource:

string xsltComponentId = xsltMMComponentItem.GetAsSource().GetValue("ID");
Component xsltMMComponent = (Component)engine.GetObject(xsltComponentId);

If someone could give me some guidance as to how I can get the component link, it would be appreciated.

2 Answers 2

11

If a component is linked as a parameter you never get the item as a component object, using Package.GetValue("name in schema") will return the string ID of the component.

From there you can use the engine.GetObject(tcmid) to get the object.

Hope this helps xxx

1
  • whoops didn't meant to add some kisses to the end of this answer - ah well it's good to spread some love into the community :)
    – johnwinter
    Commented Oct 25, 2013 at 19:14
2

Do this way:

String ID = Package.GetValue("inputValue");
Component component = (Component)mEngine.GetObject(ID);
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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