How to create taxonomy field with CSOM

If you need to programmatic create a taxonomy field, you need to:

  1. Know the termstore id and termset id that associated with this column
  2. Create a taxonomy field with schema include some basic attributes
  3. Update some essential attributes for the taxonomy field
            //Add field as xml with some basic attribute
XElement fieldSchema = new XElement("Field");
fieldSchema.SetAttributeValue("Type", "TaxonomyFieldType");
fieldSchema.SetAttributeValue("DisplayName", "TestField"); list.Fields.AddFieldAsXml(fieldSchema.ToString(), true, AddFieldOptions.DefaultValue); context.ExecuteQuery(); //get taxonomy field
context.Load(list.Fields, fields => fields.IncludeWithDefaultProperties().Where(f => f.Title == "TestField"));
context.ExecuteQuery(); var taxonomyField = list.Fields[] as TaxonomyField; //Update essential attributes for taxonomy field // Specify the Id of termset associated with the column
taxonomyField.TermSetId = new Guid("a518b741-e2eb-429a-8dc7-f737945b25a3");
// Id of the term store
taxonomyField.SspId = new Guid("151320eb-50d2-468d-b42e-1531301953a7"); taxonomyField.Update(); context.ExecuteQuery();

How to update taxonomy field value with CSOM

If you need to programmatic update taxonomy field value, you need to get the term id and label first. This sample shows how to update taxonomy field with multiple values.

            ListItem item = list.GetItemById();

            TaxonomyFieldValueCollection col = new TaxonomyFieldValueCollection(context, "", taxonomyField);
col.PopulateFromLabelGuidPairs("invrev-mel|44c3035c-b84b-4da3-b7fc-1097ab5e07e2;BEE|c0e6e20a-142f-4f07-ac10-3cf1aa692b13;05 Industry Data and News|b4030964-270b-4f80-bedd-0c2d9d7fae22"); taxonomyField.SetFieldValueByValueCollection(item, col);

Working With Taxonomy Field in CSOM的更多相关文章

  1. SharePoint 2013 Create taxonomy field

    创建taxonomy field之前我们首先来学习一下如果创建termSet,原因是我们所创建的taxonomy field需要关联到termSet. 简单介绍一下Taxonomy Term Stor ...

  2. Creating fields using CSOM

      When creating a field, whether you are using CAML, server-side object mode, or one of the client-s ...

  3. share point CSOM 客户端模式 创建 list

    /// <summary> /// 创建新的列表 list /// </summary> /// <param name="web"></ ...

  4. 详细分析Orchard的Content、Drivers, Shapes and Placement 类型

    本文原文来自:http://skywalkersoftwaredevelopment.net/blog/a-closer-look-at-content-types-drivers-shapes-an ...

  5. wordpress---wp_query的使用方法

    wp_query是一个wordpress用于复杂请求的的一个类,看到query懂开发的人就会反应这个是数据库查询的一个类,这个类可谓是非常有用的,可以帮助我们做很多复杂的查询. wp_query的使用 ...

  6. SharePoint 2013 Create Folder with conententtype programer

    记录一下昨天写的SharePoint tool,需求是这样的: 在SharePoint list subfolder 下创建1000个folder,这些folder指定特殊的contenttype,c ...

  7. SharePoint 2013 开发——CSOM概要

    博客地址:http://blog.csdn.net/FoxDave 本篇对客户端API做一个大致地了解. 看一下各个类别主要API之间的对应关系表. 假设我们对Server API已经有了足够地了 ...

  8. share point CSOM 客户端模式 创建表 增删改查

    需要引用:Microsoft.SharePoint.Client ascx: <h4>CSOM所有表名</h4> <table> <tr> <td ...

  9. salesforce 零基础学习(六十二)获取sObject中类型为Picklist的field values(含record type)

    本篇引用以下三个链接: http://www.tgerm.com/2012/01/recordtype-specific-picklist-values.html?m=1 https://github ...

随机推荐

  1. VC++ MFC子对话框建立与关闭

    主窗体 void CMoshiwindowDlg::OnButton1() { // TODO: Add your control notification handler code here CDi ...

  2. Java设计模式——装饰者模式

    JAVA 设计模式 装饰者模式 用途 装饰者模式 (Decorator) 动态地给一个对象添加一些额外的职责.就增加功能来说,Decorator 模式相比生成子类更为灵活. 装饰者模式是一种结构式模式 ...

  3. 分享一个 jquery serializeArray()序列化方法

    http://www.365mini.com/page/jquery-serializearray.htm http://www.365mini.com/diy.php?f=jquery-serial ...

  4. RPC应用的java实现(转)

    一.RPC介绍 什么是RPC?Remote Procedure Call,远程过程调用.也就是说,调用过程代码并不是在调用者本地运行,而是要实现调用者与被调用者二地之间的连接与通信.比较严格的定义是: ...

  5. Python环境下NIPIR(ICTCLAS2014)中文分词系统使用攻略

    一.安装 官方链接:http://pynlpir.readthedocs.org/en/latest/installation.html 官方网页中介绍了几种安装方法,大家根据个人需要,自行参考!我采 ...

  6. linux特殊符号大全

    #   ;   ;;      .      ,       /       \       'string'|       !   $   ${}   $?      $$   $*  " ...

  7. Notepad++ 快捷键 大全

    Notepad++ 快捷键 大全Ctrl+C 复制Ctrl+X 剪切Ctrl+V 粘贴Ctrl+Z 撤消Ctrl+Y 恢复Ctrl+A 全选Ctrl+F 键查找对话框启动Ctrl+H 查找/替换对话框 ...

  8. 【Lua】Debian环境下openresty的安装

    OpenResty (也称为 ngx_openresty)是一个全功能的 Web 应用服务器,它打包了标准的 Nginx 核心,很多的常用的第三方模块,以及它们的大多数依赖项. OpenResty 通 ...

  9. 复利test

    因为上节课老师有给我们讲了单元测试的概念及其基本操作,我就对我之前的复利计算器进行了改进和测试.因为从控制台的简单输入输出对单元测试来说不够完善,便参考了其他同学的优秀编程又重新写了一个复利计算器的框 ...

  10. 万万没想到,3D打印居然可以做这些逆天设计

    3D打印一直被冠以“高科技”头衔,似乎离我们的日常生活还很遥远.其实不然,随着技术的创新,3D打印技术逐渐深入各个领域,工业生产.商业.医学.建筑.艺术等领域都能看到3D打印技术的影子.它将会改变我们 ...