深入浅出SharePoint——获取Choice Field的Mapping value
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的更多相关文章
- sharepoint获取exchange邮箱报错:该帐户无权模拟所请求的用户
现象: sharepoint获取exchange邮箱报错:该帐户无权模拟所请求的用户 处理办法: 1.Open the Exchange Management Shell 2.输入: New-Mana ...
- 如何在django-filter中用choice field 的 value 值过滤对象
如果我们有这样一个model: class IPInfoModel(models.Model): TYPE_INTRANET = 1 TYPE_INTERNET = 2 IP_TYPES = ( (T ...
- Flask WTForm disable choice field
Flask disable choice field ChoiceField = { render_kw={'disabled':''} } form.my_field.render_kw = {'d ...
- SharePoint 获取Lookup 字段的值
获取某个List里的Lookup字段的值是很普遍的事,那么我们将它封装起来 获取Lookup字段值的方法: /// <summary> /// To get lookup field Id ...
- SharePoint 获取详细Log信息
在SharePoint的运维当中,我们可能经常会遇到排错,但是即使找到日志,也不是特别的详细,我们还是需要各种无厘头的猜测. 其实,SharePoint是可以打开详细的日志的,尤其是面对一些服务产生的 ...
- SharePoint Development - Custom Field using Visual Studio 2010 based SharePoint 2010
博客地址 http://blog.csdn.net/foxdave 自定义列表的时候有时候需要自定义一些字段来更好地实现列表的功能,本文讲述自定义字段的一般步骤 打开Visual Studio,我们还 ...
- SharePoint 获取服务器场管理员密码
前言 这还是很久以前发生的故事(你也可以说事故),公司新来的小朋友帮客户运维,然后,因为客户要改场管理员密码,这个很简单啊,我们有密码变更的文档.小朋友分分钟就帮客户把密码更新了,然后,就去干别的了. ...
- sharepoint获取域名和当前登录的应为名字
string a = SPContext.Current.Web.CurrentUser.ToString(); int length = a.IndexOf("w|", 0) ...
- 深入浅出SharePoint2013——获取Application Pool的id和name对照表
PS C:\Users\Mingle> Get-SPServiceApplicationPool | select Id, Name Id Name-- ----f864f712-faa4-4a ...
随机推荐
- 深入理解java集合框架之---------Arraylist集合 -----添加方法
Arraylist集合 -----添加方法 1.add(E e) 向集合中添加元素 /** * 检查数组容量是否够用 * @param minCapacity */ public void ensur ...
- 10w定时任务,如何高效触发超时
一.缘起 很多时候,业务有定时任务或者定时超时的需求,当任务量很大时,可能需要维护大量的timer,或者进行低效的扫描. 例如:58到家APP实时消息通道系统,对每个用户会维护一个APP到服务器的TC ...
- Windump 的用法/Windump 是什么?
Windump Windump是Windows环境下一款经典的网络协议分析软件,其Unix版本名称为Tcpdump.它可以捕捉网络上两台电脑之间所有的数据包,供网络管理员/入侵分析员做进一步流量分 ...
- 使用 Redis 实现分布式锁(转载)
背景 在一般的分布式应用中,要安全有效地同步多服务器多进程之间的共享资源访问,就要涉及到分布式锁.目前项目是基于 Tornado 实现的分布式部署,同时也使用了 Redis 作为缓存.参考了一些资料并 ...
- 学会了ES6,就不会写出那样的代码
用let不用var ES6之前我们用var声明一个变量,但是它有很多弊病: 因为没有块级作用域,很容易声明全局变量 变量提升 可以重复声明 还记得这道面试题吗? var a = []; for (va ...
- json和xml以及ajax的数据格式用法
JSON的两个方法: 1.将字符串转换为JSON格式:parse(). 2.将原生JavaScript值转换为JSON字符串:stringify(); <!DOCTYPE html> &l ...
- 【译】Steve Yegge的文章《Practicing Programming》
与你所相信的恰恰相反,单纯地每天埋头于工作并不能算是真正意义上的锻炼——参加会议并不能锻炼你的人际交往能力:回复邮件并不能提高你的打字水平.你必须定期留出时间,集中锻炼,这样才能把事情做得更好.我认识 ...
- jQuery的三种$()方式
http://www.jb51.net/article/21660.htm $号是jQuery“类”的一个别称,$()构造了一个jQuery对象.所以,“$()”可以叫做jQuery的构造函数(个 ...
- ADO MFC SQL2000
对于初学VC的朋友来说,连接数据库其实是一件不容易的事情.记得我当时为了与数据库连接上,找了好多资料,上网看了好多文章,都没有解决这个问题.后 来,有个网友帮我解决了,我再次表示感谢.为了后来VC初学 ...
- intellij idea Entity类报错“Cannot resolve table”
https://blog.csdn.net/u014290233/article/details/54311954 转载,以便下次查看