list field对应的caml定义如下

      <Field Type="Choice" DisplayName="Inspection Result" Required="FALSE" Format="RadioButtons" FillInChoice="FALSE" Group="C0370A" ID="{5D00E04C-9BA6-4f78-BC51-2D2EC2C2EC73}" SourceID="{1e228f79-b273-49cd-b9cc-507b1ecc7c5c}" StaticName="VPPI_InspectionResult" Name="VPPI_InspectionResult"  >
<CHOICES>
<CHOICE>Satisfactory</CHOICE>
<CHOICE>Unsatisfactory – but no assistance is needed</CHOICE>
<CHOICE>Unsatisfactory – I need assistance</CHOICE>
</CHOICES>
<MAPPINGS>
<MAPPING Value="1">Satisfactory</MAPPING>
<MAPPING Value="2">Unsatisfactory – but no assistance is needed</MAPPING>
<MAPPING Value="3">Unsatisfactory – I need assistance</MAPPING>
</MAPPINGS>
</Field>

Console应用程序:

读取第一个item中choice单选类型的field的value值

class Program
{
static void Main(string[] args)
{
using (SPSite site = new SPSite("http://cris-moss/sites/EHS"))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["Safety Inspection Verification"];
if (list != null)
{
SPListItem item = list.Items[];
SPFieldChoice chVisiblity = (SPFieldChoice)item.Fields.GetField("VPPI_InspectionResult");
object value = item["VPPI_InspectionResult"];
string selectedText = chVisiblity.GetFieldValueAsText(item["VPPI_InspectionResult"]);
Console.WriteLine("The value of the field is {0}, which means '{1}'.",
value.ToString(), GetMappingValueforSPFieldChoice(selectedText,chVisiblity.Mappings));
}
Console.ReadLine();
}
}
} static string GetMappingValueforSPFieldChoice(string selectedText,string mappings)
{
string selectedValue = string.Empty;
XmlDocument doc=new XmlDocument();
doc.LoadXml(mappings);
XmlNode node = doc.SelectSingleNode("MAPPINGS/MAPPING[text()='" + selectedText + "']");
selectedValue = node.Attributes["Value"].Value;
return selectedValue;
}
}

深入浅出SharePoint——获取Choice Field的Mapping value的更多相关文章

  1. sharepoint获取exchange邮箱报错:该帐户无权模拟所请求的用户

    现象: sharepoint获取exchange邮箱报错:该帐户无权模拟所请求的用户 处理办法: 1.Open the Exchange Management Shell 2.输入: New-Mana ...

  2. 如何在django-filter中用choice field 的 value 值过滤对象

    如果我们有这样一个model: class IPInfoModel(models.Model): TYPE_INTRANET = 1 TYPE_INTERNET = 2 IP_TYPES = ( (T ...

  3. Flask WTForm disable choice field

    Flask disable choice field ChoiceField = { render_kw={'disabled':''} } form.my_field.render_kw = {'d ...

  4. SharePoint 获取Lookup 字段的值

    获取某个List里的Lookup字段的值是很普遍的事,那么我们将它封装起来 获取Lookup字段值的方法: /// <summary> /// To get lookup field Id ...

  5. SharePoint 获取详细Log信息

    在SharePoint的运维当中,我们可能经常会遇到排错,但是即使找到日志,也不是特别的详细,我们还是需要各种无厘头的猜测. 其实,SharePoint是可以打开详细的日志的,尤其是面对一些服务产生的 ...

  6. SharePoint Development - Custom Field using Visual Studio 2010 based SharePoint 2010

    博客地址 http://blog.csdn.net/foxdave 自定义列表的时候有时候需要自定义一些字段来更好地实现列表的功能,本文讲述自定义字段的一般步骤 打开Visual Studio,我们还 ...

  7. SharePoint 获取服务器场管理员密码

    前言 这还是很久以前发生的故事(你也可以说事故),公司新来的小朋友帮客户运维,然后,因为客户要改场管理员密码,这个很简单啊,我们有密码变更的文档.小朋友分分钟就帮客户把密码更新了,然后,就去干别的了. ...

  8. sharepoint获取域名和当前登录的应为名字

    string a =  SPContext.Current.Web.CurrentUser.ToString(); int length = a.IndexOf("w|", 0) ...

  9. 深入浅出SharePoint2013——获取Application Pool的id和name对照表

    PS C:\Users\Mingle> Get-SPServiceApplicationPool | select Id, Name Id Name-- ----f864f712-faa4-4a ...

随机推荐

  1. js Array vs [],以及是否为空的判断

    两者基本相同,唯一不同点在于初始化: var a = [], // these are the same b = new Array(), // a and b are arrays with len ...

  2. leetcode:N-Queens 问题

    一.N-QueensII class Solution { public: int totalNQueens(int n) { ; vector<); dfs(,n,total,v); retu ...

  3. Elastic Kibana - Install as windows service

    #1 通过windows sc 服务命令安装 sc create "Kibana661" binPath= "{path}\kibana.bat" depend ...

  4. 《Think Python》第6章学习笔记

    目录 6.1 返回函数值(Return values) 6.2 增量式开发(Incremental development) 6.3 组合(Composition) 6.4 布尔函数(Boolean ...

  5. ORACLE: private ,dao中util执行规范,nextval计数把通过nextval插入但已删除的列也统计在内向后计数

    private DAO中的util.rs.sql都应该为private. 其中每个具体方法执行增删改查操作前打开数据库连接,操作完成后关闭数据库连接.操作要规范,不然易出错. nextval seq_ ...

  6. 使用javascript获取wx.config内部字段解决微信分享

    背景 在微信分享开发的时候我们通常的流程是 <?php require_once "jssdk.php"; $jssdk = new JSSDK("yourAppI ...

  7. 字符串数组中含有json转换

    [{'a':'1','b':'2'},{'c':'3','d':'4'}]" 解决 import net.sf.json.JSONArray; import net.sf.json.JSON ...

  8. bnu 4060 奇偶性,异或运算

    Plants vs. Zombies Time Limit: 5000ms Memory Limit: 2048KB   64-bit integer IO format: %lld      Jav ...

  9. JAVA_吸血鬼数字 多种方法实现

    package test4; import java.util.Arrays; /** * 从TIJ中第4章的练习10看到“吸血鬼数字”,以下几种方法实现以及执行时间对比 * 找出四位数的所有吸血鬼数 ...

  10. 《JavaWeb从入门到改行》很好的复习资料: SQL语句到底怎么写 ?

    本文用到的数据库如下: CREATE DATABASE exam; /创建部门表/ CREATE TABLE dept( deptno INT PRIMARY KEY, dname ), loc ) ...