嘿所有我希望将一些数据添加到我的sharepoint网站的列表中。
以下代码是我尝试使用的:
Dim siteUrl As String = "http://thespsite/sandbox/"
Dim clientContext As New ClientContext(siteUrl)
Dim oList As List = clientContext.Web.Lists.GetByTitle("demoT")
Dim listCreationInformation As New ListItemCreationInformation()
Dim oListItem As ListItem = oList.AddItem(listCreationInformation)
oListItem("Title") = "testing this out"
oListItem("Priority") = "(2) Normal"
oListItem("AssignedTo") = "Lastname, Firstname"
oListItem.Update()
clientContext.ExecuteQuery()
我的列表名为 demoT ,字段标题,优先级和分配给是我希望添加到列表中的所有字段。当然,姓氏,名字用SPDB中的实际名称填写。
然而,这是我得到的错误:
An exception of type 'Microsoft.SharePoint.Client.ServerException'
occurred in Microsoft.SharePoint.Client.Runtime.dll but was not
handled in user code
Additional information: Invalid data has been used to update the
list item. The field you are trying to update may be read only.
我知道评论存在,因为我在列表中看到它...只是不知道为什么它不允许我添加?如果我对代码的那部分进行评论并运行它,它就会很好地发布到列表中。
“分配给”部分的Sharepoint Designer HTML代码为:
<SharePoint:FormField runat="server" id="ff2{$Pos}" ControlMode="New"
FieldName="AssignedTo" __designer:bind="{ddwrt:DataBind('i',concat('ff2',$Pos),
'Value','ValueChanged','ID', ddwrt:EscapeDelims(string(@ID)),'@AssignedTo')}"/>
<SharePoint:FieldDescription runat="server" id="ff2description{$Pos}"
FieldName="AssignedTo" ControlMode="New"/>
我可以缺少什么来阻止它添加该字段?
答案 0 :(得分:0)
我的第一个猜测是“分配给”字段的格式错误。请参阅此处开始: