2009-08-17 83 views
0

我正在使用SharePoint,我試圖將服務呼叫添加到Microsoft呼叫中心應用程序模板。我可以只是一個名字下面的代碼添加一個:以編程方式將服務呼叫添加到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體驗?有沒有辦法確定哪些字段是隻讀的,如果有的話?

謝謝!

回答

1

指定的值,我發現,要解決這個問題,請check out this link

+0

你不需要走那麼遠才能完成這項工作。將Index值設置爲Lookup字段而不是1#Value格式就足夠了。 – Kusek 2009-08-17 17:01:19

+0

感謝您的輸入kusek – Anders 2009-08-17 17:31:46

0

這有時發生在您有查找字段並且未指定值時。例如,當你有以下項目

  1. 客戶列表:文本
  2. 部門:部門列表和所需的查找。現在

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

你會得到這個error.Because你沒有對Department字段