2014-03-19 49 views
1

列出使用下面的代码托管元数据列程序添加到列表中:添加托管元数据列在Sharepoint 2013我尝试用CSOM

  Field f = list.Fields.AddFieldAsXml("<Field Type='" + columntype + "' Name='" + columnname + "' DisplayName='" + columnname + "' ShowField='Term1033' />", true, AddFieldOptions.AddFieldToDefaultView); 

      clientContext.Load(f); 
      clientContext.ExecuteQuery(); 

      TaxonomyField taxField = clientContext.CastTo<TaxonomyField>(f); 

      taxField.SspId = this.getDefaultTermStoreId(); 
      taxField.TermSetId = getTermSetIdByName("Instanties"); 
      taxField.AllowMultipleValues = false; 
      taxField.Open = true; 

      taxField.TargetTemplate = string.Empty; 
      taxField.AnchorId = Guid.Empty; 
      taxField.Update(); 
      list.Update(); 
      clientContext.ExecuteQuery(); 

列在我的列表中创建一个托管元数据类型列但是我希望用户选择的术语没有填写在设置中。任何人都有提示设置托管元数据列的TermSet?

getDefaultTermStoreId()和getTermSetIdByName(string)给我正确的GUID;我检查了!

非常感谢!

+0

附加地修改为: taxField.TargetTemplate = string.Empty; taxField.AnchorId = Guid.Empty; – Verthosa

回答

0

我们应该加

taxField.TargetTemplate = string.Empty; taxField.AnchorId = Guid.Empty;

然后它的工作!

相关问题