I am attempting to add metadata columns to existing lists via a workflow. I can create the actual columns without a problem, and if there is only a single default term there is, again, no problem. However, when the user has specified multiple terms for the column, I cannot get all terms to become defaults. Only the last term is applied. The field is created as a TaxonomyField, with MultipleTerms enabled.
Here is what I am doing:
mdataValue = listItem["Business Units"].ToString();
string[] mdataTerms = new string[1];
if (mdataValue.Contains(';'))
{
mdataTerms = mdataValue.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
}
else
{
mdataTerms[0] = mdataValue;
}
fld = docList.Fields["Business Units"];
foreach (string s in mdataTerms)
{
mDefaults = new MetadataDefaults(docList);
mDefaults.SetFieldDefault(docList.RootFolder, fld.InternalName, "1033;#" + s);
mDefaults.Update();
}