sharepoint - 将项目添加到列表时,我收到错误 Invalid data has been used to update the list item。您尝试更新的字段可能是只读的
问题描述
我正在使用客户端对象模型来更新 SharePoint 上的列表。
列表很简单,只有 3 列([Title]、[Author]、[Year Published])
【标题】为默认添加的标准栏,
[作者] 是我自己的列,它是一个字符串字段(它不指向用户,它只是纯文本)
和 [发布年份] 发布是一个数字。
所有字段都标记为必填项。
string strUrl = "http://server/sites/training";
using (SPSite oSite = new SPSite(strUrl))
{
using (SPWeb oWeb = oSite.OpenWeb())
{
SPList list = oWeb.Lists["Books"];
SPListItem book = list.AddItem();
book["Title"] = "SQL Server Internals";
book["Author"] = "Mc Fredy";
book["Year Published"] = 2015;
book.Update();
}
}
我得到例外book.Update();
无效数据已用于更新列表项。您尝试更新的字段可能是只读的。
我查看了我在网上找到的所有内容,但没有找到任何答案。请指教。
解决方案
Author
是内部 Sharepoint 字段,其中包含有关谁创建了记录(显示名称Created By
)的信息,您无法更改它。查看此帖子以找出您的字段的内部名称并尝试使用它。
推荐阅读
- python - 将字典附加到列表会覆盖 Python 中的所有字典
- javascript - 为什么我的按钮不起作用?
- mongodb - MongoDB更新奇怪的行为
- java - 文件字符集更改为 docker 容器中的二进制文件
- symfony - 字符串的长度树枝计数错误
- jmeter - Jmeter:聚合图显示使用合并结果插件的平均线程数
- opencv - 打开 CV 编解码器 FFMPEG 错误后备以使用标记 0x7634706d/'mp4v'
- laravel - Laravel 5想要访问模型中的auth用户ID
- php - 如何在php中的单个网页上使用两个下拉菜单
- webpack - 如何通过 webpack 插件将常规 commonjs 模块转换为外部模块?