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. "Asp.Net Web Api MediaTypeFormatter Error for x-www-formurlencoded data" 解决方法

    遇到标题中所说的问题原因是使用 jQuery AJAX 以 POST 方式调用 Asp.Net Web API .解决办法请看以下代码中有注释的部分. public static class WebA ...

  2. 1.Mybatis原理

    Mybatis是一个持久层框架,Apache底下的一个项目,它的前身是ibatis,它支持普通的SQL查询,存储过程和高级映射的优秀框架.Mybatis消除了几乎所有的JDBC代码和参数的手工设置以及 ...

  3. Volley框架之网络请求和图片加载

    Volley是 Google 推出的 Android 异步网络请求框架和图片加载框架. Volley的特性 (1).封装了的异步的请求API.Volley 中大多是基于接口的设计,可配置性强.(2). ...

  4. (转)MVC,MVP 和 MVVM 的图示

    作者: 阮一峰 日期: 2015年2月 1日 复杂的软件必须有清晰合理的架构,否则无法开发和维护. MVC(Model-View-Controller)是最常见的软件架构之一,业界有着广泛应用.它本身 ...

  5. IOS设计模式第一篇之MVC

    设计模式的好处:我们可以写出容易理解,重用度很高的代码.降低代码的耦合度,符合软件工程的思想. 设计模式主要分为三类:创造型的:单例和抽象工厂.结构类型的: MVC  Decorator, Adapt ...

  6. AngularJS学习--- AngularJS中模板链接和图像 ng-src step6

    接上一篇文章,本文将主要介绍angularjs中的模板链接,和图像显示? 首先,切换分支,启动项目: git checkout step- npm start 1.效果 相较于前一篇文章,明显感觉多了 ...

  7. c#开发Mongo笔记第六篇

    之前写的五篇比较得到了大家的积极反馈,也有个别高手对我写我写出的代码进行了指教. 其中提到的我写的查询方法性能有问题,我想了想,如果mongo不是延时加载的话,那我的查询就真的有问题了,就成了查询出来 ...

  8. 实现关闭窗口IE不提示兼容火狐

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...

  9. 再见Unity3d的死循环

    前两天看见http://www.manew.com/thread-89909-1-1.html这篇译文之前几个小时刚好解决了一个莫名的死循环问题,然后忍不住要把另外一种方法告诉蛮友们.这个方法不需要知 ...

  10. tesseract-ocr 出现 错误 Please make sure the TESSDATA_PREFIX environment variable is set to the parent d irectory of your "tessdata" directory.解决方案

    简单就是说把tessdata拷贝到exe的所在目录,或者设置TESSDATA_PREFIX环境变量