I'm trying to add values in the components field using core service API's.Component have embedded field with multi-value.when i am trying to add field value it is updating first field value and not adding new field. code sample is as follows:
var schemaFields = client.ReadSchemaFields("tcm:1030-19313-8", true, new ReadOptions());
// load a component based on that schema
var component = (ComponentData)client.Read("tcm:1030-19314", new ReadOptions());
//Console.WriteLine(component.Content);
// build a magical Fields object from it
var fields = Fields.ForContentOf(schemaFields, component);
// let's first quickly list all values of all fields
foreach (var field in fields)
{
if (field.Type == typeof(EmbeddedSchemaFieldDefinitionData))
{
Fields embededFields = fields[field.Name].GetSubFields();
embededFields["SourceID"].Value = "vcvcv";
embededFields["TargetTCMID"].Value = "vcvcv";
}
}
FullVersionInfo itemInfo = null;
itemInfo = (FullVersionInfo)component.VersionInfo;
if (itemInfo.LockType.Value != LockType.CheckedOut)
{
client.CheckOut("tcm:1030-19314", true, new ReadOptions());
component.Content = fields.ToString();
client.Save(component, new ReadOptions());
client.CheckIn("tcm:1030-19314", new ReadOptions());
}
Schema is as follows:
It has only one embedded field Mapping and Mapping have two text fields SourceID,TargetTCMID
I tried AddValues() also
Actually I am new to Core Service Concept...can you please help me on this issue...
Thanks in Advance.