SharePoint 2013 Create taxonomy field
创建taxonomy field之前我们首先来学习一下如果创建termSet,原因是我们所创建的taxonomy field需要关联到termSet。
简单介绍一下Taxonomy Term Store的层次结构:
TermStore
Group
TermSet
Term //Term可以继续创建Term
1、首先,我们需要new TaxonomySession对象,然后获取到TermStore
TaxonomySession session = new TaxonomySession(Site);//Site即为SPSite对象
TermStore termStore = session.TermStores[MetadataService];//MetadataService 即为SharePoint Managed Metadata Service name, 如果没有即需要创建一个Managed Metadata Service,具体如何创建这里不做介绍。
2、创建Group,创建Group之前我们需要check一下Group是否存在,我们可以简单的通过Linq语句来完成所需要的工作
Group group = termStore.Groups.Where(g => g.Name.Equals(groupName, StringComparison.OrdinalIgnoreCase)).Count() > ?
termStore.Groups[groupName] : termStore.CreateGroup(groupName);
3、创建TermSet,创建TermSet的时候可以指定TermSet的Lcid,我们可以通过如下2中方式获取
int lcid = termStore.DefaultLanguage;//推荐
//or
int lcid = CultureInfo.CurrentCulture.LCID;//不推荐,原因是机器语言和SharePoint环境语言有可能不一致
TermSet rootTermSet = group.TermSets.Where(ts => ts.Name == termSetName).Count() > ?
group.TermSets[termSetName] : group.CreateTermSet(termSetName, Guid.NewGuid(), lcid);
4、创建Term
Term term = rootTermSet.Terms.Where(t => t.Name.Equals(termname, StringComparison.OrdinalIgnoreCase)).Count() > ?
rootTermSet.Terms[termname] : rootTermSet.CreateTerm(termname, lcid, Guid.NewGuid());
5、commit
termStore.CommitAll();
6、创建Taxonomy field
TaxonomyField taxonomyField = Site.RootWeb.Fields.CreateNewField("TaxonomyFieldType", "taxonomyFieldName") as TaxonomyField;
taxonomyField.Description = "This is test for cnblogs.";
taxonomyField.SspId = termStore.Id;
taxonomyField.TermSetId = rootTermSet.Id;//taxonomy field binding to termSet
taxonomyField.AllowMultipleValues = true;
taxonomyField.Group = "Custom Columns";//taxonmy field default site column group
Site.RootWeb.Fields.Add(taxonomyField);
Site.RootWeb.Update();
7、测试,获取taxonomy field
TaxonomyField field = site.RootWeb.Fields["taxonomyFieldName"] as TaxonomyField;
OK,you have been created taxonomyField successfully。
SharePoint 2013 Create taxonomy field的更多相关文章
- SharePoint 2013 create workflow by SharePoint Designer 2013
这篇文章主要基于上一篇http://www.cnblogs.com/qindy/p/6242714.html的基础上,create a sample workflow by SharePoint De ...
- SharePoint 2013 Create Folder with conententtype programer
记录一下昨天写的SharePoint tool,需求是这样的: 在SharePoint list subfolder 下创建1000个folder,这些folder指定特殊的contenttype,c ...
- [SharePoint 2013] Create event receiver for external list
Main list for creating event receiver for external list Subscribe storage, it could be data table ...
- Working With Taxonomy Field in CSOM
How to create taxonomy field with CSOM If you need to programmatic create a taxonomy field, you need ...
- 移动设备和SharePoint 2013 - 第3部分:推送通知
博客地址:http://blog.csdn.net/foxdave 原文地址 在该系列文章中,作者展示了SharePoint 2013最显著的新功能概观--对移动设备的支持. 该系列文章: 移动设备和 ...
- Create a “% Complete” Progress Bar with JS Link in SharePoint 2013
Create a “% Complete” Progress Bar with JS Link in SharePoint 2013 SharePoint 2013 has a lot new fea ...
- SharePoint 2013 configure and publish infopth
This article will simply descript how to configure and publish a InfoPath step by step. Note: To con ...
- Creating Custom Connector Sending Claims with SharePoint 2013
from:http://blogs.msdn.com/b/security_trimming_in_sharepoint_2013/archive/2012/10/29/creating-custom ...
- 解决SharePoint 2013 designer workflow 在发布的报错“负载平衡没有设置”The workflow files were saved but cannot be run.
原因是app management service没有设置好,在管理中心把他删掉,重新建一个就可以了 Provision App Management Service In SharePoint 20 ...
随机推荐
- LeetCode-5LongestPalindromicSubstring(C#)
# 题目 5. Longest Palindromic Substring Given a string S, find the longest palindromic substring in S. ...
- Java中的多态
1.多态:具有表现多种形态的能力的特征 父类: public abstract class Animal {public abstract void Say();} 子类: public class ...
- 百度 flash html5自切换 多文件异步上传控件webuploader基本用法
双核浏览器下在chrome内核中使用uploadify总有302问题,也不知道如何修复,之所以喜欢360浏览器是因为帮客户控制渲染内核: 若页面需默认用极速核,增加标签:<meta name=& ...
- 【微框架】之一:从零开始,轻松搞定SpringCloud微框架系列--开山篇(spring boot 小demo)
Spring顶级框架有众多,那么接下的篇幅,我将重点讲解SpringCloud微框架的实现 Spring 顶级项目,包含众多,我们重点学习一下,SpringCloud项目以及SpringBoot项目 ...
- [C#] 回眸 C# 的前世今生 - 见证 C# 6.0 的新语法特性
回眸 C# 的前世今生 - 见证 C# 6.0 的新语法特性 序 目前最新的版本是 C# 7.0,VS 的最新版本为 Visual Studio 2017 RC,两者都尚未进入正式阶段.C# 6.0 ...
- 菜鸟Python学习笔记第二天:关于Python黑客。
2016年1月5日 星期四 天气:还好 一直不知道自己为什么要去学Python,其实Python能做到的Java都可以做到,Python有的有点Java也有,而且Java还是必修课,可是就是不愿意去学 ...
- Html 制作相册
本文主要讲述采用Html5+jQuery+CSS 制作相册的小小记录. 主要功能点: Html5进行布局 调用jQuery(借用官网的一句话:The Write Less, Do More)极大的简化 ...
- java中的内部类总结
内部类不是很好理解,但说白了其实也就是一个类中还包含着另外一个类 如同一个人是由大脑.肢体.器官等身体结果组成,而内部类相当于其中的某个器官之一,例如心脏:它也有自己的属性和行为(血液.跳动) 显然, ...
- Ubuntu安装redis并配置远程、密码以及开启php扩展
一.前言 redis是当前流行的nosql数据库,很多网站都用它来做缓存,今天我们来安装并配置下redis 二.安装并配置redis 1.安装redis sudo apt-get install re ...
- 如何查看w3p.exe 和IIS 应用程序池的关系
图形界面方式 命令行方式 如果找不到 appcmd Appcmd.exe exists at the location %systemroot%\system32\inetsrv\. You eith ...