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>

时间: 2024-12-18 23:00:07

SharePoint: Create managed metadata field programatically的相关文章

Managed Metadata Service Application(三)创建Managed Metadata Column

Create Managed Metadata Column 创建完Managed Metadata Service Application 并且创建好term之后,就可以应用到Site里了.使用ManagedMetadata Column的好处就是,管理员可以再Central Administration里进行统一的管理. 找到一个List/Library,点Create Column, 选择Managed Metadata: 在Term Set Settings 里选择term,可以到任意级

Managed Metadata Service Application(六) Managed Navigation

 Managed Navigation 在SharePoint里面,有两个导航栏,一个是上方的全局导航,一个是在左面的当前导航.有了Managed Metadata Service之后,除了传统的结构式导航,现在也可以借助ManagedMetadata Service 设置导航. 在使用之前,先保证Site Collection和Site级别都开启了Publishing feature.下面的是Site级别的Feature: 下面是Site Collection级别的Feature: 然后进

Managed Metadata Service Application(一)创建Managed Metadata Service Application

 创建Managed MetadataService Application   SharePoint Managed Metadata Service是SharePoint里面非常重要用处广泛的一个服务.User Profile Service Application和Search ServiceApplication的某些功能都依赖于它. 要创建Managed Metadata Service Application,首先以farmadministrator的身份登录到Central A

Managed Metadata Service Application(七)权限管理

 MMS Permission Managed Metadata Service 要被整个Farm使用,那么究竟谁有权限来管理term呢? 通常情况下,管理term的事情不应该有Farm Administrator来做的,而是应该具体到业务部门,因为只有他们知道需要如何管理term.SharePoint 采用了自上而下分层的权限设计来给不同的人分配不同的管理权限.从大到小为:服务器场管理员,术语库管理员,组管理员和参与者. 服务器场管理员(FarmAdministrator) 毋庸置疑,服务

Managed Metadata Service Application(四)Enterprise metadata and keywords

Enterprise Metadata and Keywords SharePoint List/Library的设定里,有一个设定叫Enterprise metadata and keywords settings.点击Ribbon上的List Settings, 这里面有Enterprise Metadata and Keywords Settings: 默认这个功能是关闭的,选中Enterprise Keywords的checkbox: 这样,再编辑一个item的时候,就多出来了一个col

Managed Metadata Service Application(五) Tag

Tag SharePoint 2013里面,创建完Managed Metadata Service Application之后,用户可以对文档或者列表项添加tag,方便用户使用. 在Managed Metadata Service里面,有一个默认的Term set叫keywords: 在这里建几个term. 选中一个Item或者文档,在Ribbon上就可以点击Tag&Note: 在弹出的页面,选择已经存在的keyword: tag会显示在Mysite里,并且在当前页面也会显示历史记录:

Managed Metadata Service Application(二)Managed Metadata Service Application常见错误

 上一篇(Managed Metadata Service Application(一)创建Managed Metadata Service Application)说到了如何创建一个新的Managed Metadata Service Application. 创建完之后,或者是在使用过程中,经常会遇到一个错误--The Managed Metadata Service or Connection is currently not available: 一般情况下,有两个原因会导致这个错误

Creating fields using CSOM

? When creating a field, whether you are using CAML, server-side object mode, or one of the client-side object models, you typically specify the following attributes: The?ID?of the fied, which is a GUID The?Name, which is the internal name of the fie

SharePoint 2013 Create Folder with conententtype programer

记录一下昨天写的SharePoint tool,需求是这样的: 在SharePoint list subfolder 下创建1000个folder,这些folder指定特殊的contenttype,contenttype中有一个Taxonomy类型的field,为这个filed赋值,并且新创建的这些folder下只能创建指定contenttype的file. 创建folder的代码如下: public static void CreatFolder(string siteUrl)//传入site