Logo

Logo

无效的数据被用来用作更新列表项 Invalid data has been used to update the list item. The field you are trying to update may be read only.

Pastore Antonio
Pastore Antonio 2022年06月17日
119 阅读 0 评论 约 1147 字 阅读约 3 分钟

无效的数据被用来用作更新列表项 Invalid data has been used to update the list item. The field you are trying to update may be read only.

     在SharePoint开发中,当我们对列表项进行添加、删除、修改的时候,更多的只注意到了常见Columns类型,如“Single line of text”,“Multiple lines of text”,“Choice (menu to choose from)”等等,而这些Columns的值很好处理,在代码中就是String、Int、DateTime类型,只要对应上了就OK了。

      但是我们很有可能会不小心或这说错误的给一个类型的Column赋了错误的值,这个Column的类型就是“Person or Group”。

     很多时候,我们看到或操作的“Person or Group”类型的值就是DisplayName或LoginName,直觉判断就是String类型的值,但是,如果在给“Person or Group”类型的Column赋值时一定要小心:“Person or Group”的数据类型是“SPUser”

     如下所示:

     image

   在这里,直接给“Person or Group”类型的Column赋值为Stirng类型的了,才会酿成此祸。立马修改代码,如下图所示:

  image

   非常完美,代码执行通过,没有问题。

   总结:

   当我们对一个类型为“Person or Group”的Column赋值时,一定要将“SPUser”赋给它,可以通过SharePoint内置方法直接获取SPUser对象,也可以将”Domain\\UserName”通过SPWeb.EnsureUser()方法转换为SPUser对象,然后赋值。

 作者: 期星揽月——每天进步一点点……

 出处:http://qixing_gan.cnblogs.com/

 版权:本文版权归作者和博客园共有,欢迎转载,但必须保留作者版权,并给出原文链接,谢谢合作!

与我在线交流

查看完整代码

橙子主题打折出售

其实我不卖,主要是这里是放广告的,所以就放了一个
毕竟主题都没做完,卖了也是坑.

购买它
部分文章可能存在转载,如果涉及到侵权,请联系删除文章。

留言板

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

3 - 2 = ?

探索AIGC相关的精彩内容,共 15 篇文章

Azure AI 服务之语音识别

简介 Azure AI 服务中的语音识别 API 是微软提供的一项先进技术,旨在帮助开发者轻松实现语 ... 无效的数据被用来用作更新列表项 Invalid data has been used to update the list item. The field you are trying to update may be read only.

2026-02-17 · Xzavier Aaron
MCP | 一文详解什么是 MCP以及 MCP 可以做什么

一、什么是 MCP MCP(Model Context Protocol)是一个专为大型语言模型(L ... 无效的数据被用来用作更新列表项 Invalid data has been used to update the list item. The field you are trying to update may be read only.

2026-02-14 · Shen, Luke
你的工作流程,值得一个“全自动数字分身”:录制、截图、成文,一气呵成

一、一句话认识 TestFlow Recorder 在数字化工作环境中,如何准确记录操作步骤并生成清 ... 无效的数据被用来用作更新列表项 Invalid data has been used to update the list item. The field you are trying to update may be read only.

2026-02-14 · Xzavier Aaron
Flowise 前端框架配置指南

用户需求 问题:有没有适合配置 Flowise 的前端框架? 目标:寻找类似 Open WebUI ... 无效的数据被用来用作更新列表项 Invalid data has been used to update the list item. The field you are trying to update may be read only.

2026-02-14 · Xzavier Aaron