zoukankan      html  css  js  c++  java
  • SharePoint: Create managed metadata field programatically

    The following piece of code creates a managed metadata column with internal name "BusinessLocation" and display name "Business Location"

    using (SPSite site = new SPSite("http://intranet.contoso.com/sites/contracts"))
    {
        using (SPWeb web = site.OpenWeb())
        {                 
            TaxonomySession taxonomySession = new TaxonomySession(site);
            TermStore termStore = taxonomySession.TermStores["Managed Metadata Service"];
            Group group = termStore.Groups["Corporate Taxonomy"];
            TermSet termset = group.TermSets["Geography"];
            TaxonomyField taxonomyField = web.Fields.CreateNewField("TaxonomyFieldType", "BusinessLocation") as TaxonomyField;
            taxonomyField.Description = "Loction of business house.";
            taxonomyField.SspId = termStore.Id;
            taxonomyField.TermSetId = termset.Id;
            taxonomyField.AllowMultipleValues = false;
            taxonomyField.Group = "My Content Types";
            web.Fields.Add(taxonomyField);
            TaxonomyField field = site.RootWeb.Fields["BusinessLocation"] as TaxonomyField;
            field.Title = "Business Location";
            field.Update(true);
        }
    }

    来自 <http://www.sharepointnadeem.com/2012/02/create-managed-metadata-field.html

    如果,您认为阅读这篇博客对你有帮助,点击一下左下角的[推荐] 如果,你想了解我的动态,点击一下左下角的[关注我] 因为,你们的支持正是我学习的动力 如需转载,请注明出处 如果对文章有任何问题,都可以再评论中留言,我会尽可能的答复您,谢谢你的阅读
  • 相关阅读:
    微信端video去除最顶层播放
    MVC错误页面相关说明
    sublime使用
    linux或Mac下手动回滚代码
    用Python操作git命令
    利用pyinstaller打包加密Python项目
    进程、线程和协程的结合使用
    模块导入失败问题
    递归调用解压zip包或rar包
    随机验证码&发红包
  • 原文地址:https://www.cnblogs.com/stevegp/p/4156434.html
Copyright © 2011-2022 走看看