Sharepoint 2010 使用客户端对象模型添加列表项

Sharepoint 2010 使用客户端对象模型添加列表项,sharepoint-2010,sharepoint-clientobject,Sharepoint 2010,Sharepoint Clientobject,我目前正在开发一个Windows应用程序,用于将数据从旧系统迁移到SharePoint列表中 为此,我访问客户机对象模型,并使用它创建新的列表项和更新相关字段值 我遇到的问题是,有些字段值会更新,有些则不会。看起来好像有些选项字段没有保留传递的值……甚至标题字段也没有保留该值。调查显示,有问题的选择字段是单选按钮和多值选择的组合 下面是我正在使用的代码。有人能解释一下为什么会发生这些问题吗 谢谢 代码: 我最终解决了这个问题,解决了在SP服务器上运行应用程序时如何使用服务器对象模型的问题 它涉及

我目前正在开发一个Windows应用程序,用于将数据从旧系统迁移到SharePoint列表中

为此,我访问客户机对象模型,并使用它创建新的列表项和更新相关字段值

我遇到的问题是,有些字段值会更新,有些则不会。看起来好像有些选项字段没有保留传递的值……甚至标题字段也没有保留该值。调查显示,有问题的选择字段是单选按钮和多值选择的组合

下面是我正在使用的代码。有人能解释一下为什么会发生这些问题吗

谢谢

代码:


我最终解决了这个问题,解决了在SP服务器上运行应用程序时如何使用服务器对象模型的问题

它涉及使用SPFarm.Local、SPFarm.Services和SPWebApplication访问服务器,然后访问站点

                strDtls = Split(strData, "~^")
                Dim inf As New ListItemCreationInformation()
                Dim itmProfile As ListItem = lstProfile.AddItem(inf)
                itmProfile.Update()
                ctx.ExecuteQuery()
                strID = itmProfile.ID.ToString
                itmProfile.Item("Title") = strDtls(0)
                itmProfile.Item("Category") = strDtls(1)
                itmProfile.Item("Jurisdiction") = "Federal"
                itmProfile.Item("Other_x0020_Jurisdiction") = strDtls(3)
                itmProfile.Item("Practice_x0020_Group") = "Banking & Finance"
                dteTmp = Date.ParseExact(strDtls(5),"dd/MM/yyyy",System.Globalization.CultureInfo.InvariantCulture)
                itmProfile.Item("Last_x0020_Reviewed_x0020_Date") = dteTmp
                itmProfile.Item("Format") = "Tab through"
                itmProfile.Item("Format_x0020_specification") = strDtls(7)
                If strDtls(8) = "" then
                    usrTmp = oWeb.EnsureUser("ORG\55276")
                else
                    usrTmp = oWeb.EnsureUser("ORG\44778")
                End If
                ctx.Load(usrTmp)
                ctx.ExecuteQuery()
                usrVal1 = New FieldUserValue()
                usrVal1.LookupId = usrTmp.Id
                itmProfile.Item("Author0") = usrVal1
                If strDtls(9) = "" then
                    usrTmp2 = oWeb.EnsureUser("ORG\55276")
                else
                    usrTmp2 = oWeb.EnsureUser("ORG\" + strDtls(9))
                End If
                ctx.Load(usrTmp2)
                ctx.ExecuteQuery()
                usrVal2 = New FieldUserValue()
                usrVal2.LookupId = usrTmp2.Id
                itmProfile.Item("Partner_x0020_Responsible") = usrVal2
                itmProfile.Item("NewColumn1") = strDtls(10)
                itmProfile.Item("Engagement_x0020_type") = strDtls(11)
                itmProfile.Item("NewColumn10") = strDtls(12)
                itmProfile.Item("Audit_x0020_frequency") = strDtls(13)
                itmProfile.Item("Royalty") = strDtls(14)
                itmProfile.Item("Audit_x0020_frequency_x0020_appr") = strDtls(15)
                dteTmp = Date.ParseExact(strDtls(16),"dd/MM/yyyy",System.Globalization.CultureInfo.InvariantCulture)
                itmProfile.Item("Next_x0020_review_x0020_due") = dteTmp
                itmProfile.Item("Archive") = strDtls(17)
                itmProfile.Item("Drafted_x0020_by") = strDtls(18)
                itmProfile.Item("Partner_x0020_signoff") = strDtls(19)
                itmProfile.Item("Style_x0020_guide_x0020_complian") = strDtls(20)
                itmProfile.Item("Client") = strDtls(21)
                itmProfile.Item("Form_x0020_Details") = strDtls(22)
                itmProfile.Item("Description") = strDtls(24)
                itmProfile.Item("Reference") = strDtls(25)
                itmProfile.Update()
                ctx.Load(itmProfile)
                ctx.ExecuteQuery()