Search code examples
tridiontridion-2011

How to set the Multimedia Link field using Core service?


I would like to set the Multimedia link fied for the component metadata using core service.

I am trying like below, am getting xml validation error. could you pleaes help on this?

        ComponentData comp = client.Read(compid, readoption) as ComponentData;
        comp = client.TryCheckOut(compid, readoption) as ComponentData;

        string newxml = @"<Metadata xmlns=""uuid:5880d67f-13f7-4632-8c33-dcfd9c1437ed"">
                          <meta>
                          <mmlink>tcm:22-5678</mmlink>        

                          </metad>
                          </Metadata>";

        comp.Metadata = newxml;

        client.Save(comp, readoption);
        client.CheckIn(comp.Id, readoption);

Solution

  • You should set xlink:href like here:

    <mmlink xlink:type="simple" xlink:href="tcm:2-146" 
            xmlns:xlink="http://www.w3.org/1999/xlink"></mmlink>
    

    The easiest way to solve problems like this is to create a component schema with the field in question and corresponding component. You will then find the answer by exploring component XML