以编程方式向SharePoint Call Center应用程序添加服务调用

时间:2009-08-17 15:44:54

标签: c# sharepoint

我正在使用sharepoint,我正在尝试向微软的呼叫中心应用程序模板添加服务调用。我可以使用以下代码添加一个名称:

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 个答案:

答案 0 :(得分:1)

我找到了这个问题的解决方案,请check out this link

答案 1 :(得分:0)

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

  1. 客户:文字
  2. 部门:查找部门名单并要求。

    SPListItem item = requestsList.Add();        
    item["Customer"] = "as";
    item.Update();
    
  3. 现在您将收到此错误。因为您没有指定Department字段的值