代码之家  ›  专栏  ›  技术社区  ›  Anders

以编程方式向SharePoint呼叫中心应用程序添加服务呼叫

  •  0
  • Anders  · 技术社区  · 15 年前

    我正在使用SharePoint,并尝试将服务呼叫添加到Microsoft的呼叫中心应用程序模板。我可以添加一个只有以下代码的名称:

    SPSite allSites = new SPSite(siteURL);
    SPWeb site = allSites.AllWebs[siteName];
    SPListItemCollection requestsList = site.Lists[serviceRequests].Items;
    SPListItemCollection customerList = site.Lists[customers].Items;
    
    SPListItem item = requestsList.Add();
    item["Service Request"] = "Program Test";
    //item["Customer"] = "Donald Duck";
    item["Customer"] = customerList[0];
    item.Update();
    

    首先,我试着只用客户的名字,但没用。然后我得到了客户列表并尝试使用客户列表项,但我仍然得到相同的错误:

    "Invalid data has been used to update the list item. The field you are trying to update may be read only."

    是否有人有类似代码向SharePoint添加信息的经验?如果有的话,有什么方法可以确定哪些字段是只读的吗?

    谢谢!

    2 回复  |  直到 15 年前
        1
  •  1
  •   Anders    15 年前

    我找到了这个问题的解决办法 check out this link .

        2
  •  0
  •   Kusek    15 年前

    当您有一个查找字段而没有指定其值时,就会发生这种情况。例如,当您有一个包含以下项目的列表时

    1. 客户:文本
    2. 部门:查找部门列表和必需项。

      SPListItem item = requestsList.Add();        
      item["Customer"] = "as";
      item.Update();
      

    现在,您将得到这个错误。因为您没有为Department字段指定值。