1

我有一個自定義構建的Web服務,可以將項目簡單地添加到SharePoint Foundation 2010中的列表中。我的工作流程已附加到列表中,但創建項目時使用我的Web服務(引用SharePoint對象模型)工作流程「啓動時失敗」。如果我直接在SharePoint內向列表中添加項目,工作流程將根據需要開始,而不會出現問題。我曾嘗試以下爲止(包括使用它們放在一起的所有變化),但這些不解決該問題:以編程方式將項目添加到列表時,開始時工作流程失敗

  • 使用SPSecurity.RunWithElevatedPrivilages運行我的代碼
  • 冒充不同的用戶管理員和系統帳戶創建項目爲
  • 運行我的應用程序池相同的用戶我的網站的應用程序池
  • 運行我的應用程序池不同的帳戶對Web服務沒有失敗我的網站的應用程序池的用戶 ,它是創造項目,只是工作流程沒有運行... ca任何人都可以幫我解決這個問題嗎?

的代碼我使用創建列表項如下:提前

SPSecurity.RunWithElevatedPrivileges(delegate() 
     { 

      SPSite oTempSite = new SPSite(SharePointSite); 
      SPUser oUserImpersonate = oTempSite.OpenWeb().EnsureUser(UserToEntryAs); 

      SPSite oSite = new SPSite(SharePointSite, oUserImpersonate.UserToken); 
      SPWeb oWeb = oSite.OpenWeb(); 

      try 
      { 
       oSite.AllowUnsafeUpdates = true; 
       oWeb.AllowUnsafeUpdates = true; 

       SPList oList = oWeb.Lists["Sample Log"]; 

       SPListItem oNewItem = oList.Items.Add(); 

       oNewItem["Customer"] = intCustomerID; 
       oNewItem["Cust. Contact Name"] = strCustomerContactName; 
       oNewItem["Contact Email"] = strCustomerContactEmail; 
       oNewItem["Sample Number"] = strSampleNumber; 
       oNewItem["Notes"] = strNotes; 
       oNewItem["Application"] = strSampleApplication; 
       oNewItem["Despatch Method"] = strDespatchMethod; 
       oNewItem["Cost"] = dblCost; 
       oNewItem["Sample 1"] = intSampleProductID; 
       oNewItem["Weight 1"] = strSampleWeight; 
       oNewItem["Batch No. 1"] = strSampleBatch; 

       //Handle Account Manager(s): 
       SPFieldUserValueCollection usrAccountManagers = new SPFieldUserValueCollection(); 
       foreach (string strAcctMrg in AccountManagers.Split(';')) 
       { 
        SPUser oUser = oWeb.EnsureUser(strAcctMrg); 
        usrAccountManagers.Add(new SPFieldUserValue(oWeb, oUser.ID, oUser.LoginName)); 
       } 
       oNewItem["Account Manager"] = usrAccountManagers; 

       oNewItem["Content Type"] = "Ingredient Sample"; //Set the content type to be 'Ingredient Sample' 
       oNewItem["Ingredient Sample Status"] = "Awaiting Result"; //Set the status to default to 'Awaiting Result' 

       oNewItem.Update(); 

謝謝...

+0

請從增加一項服務添加源代碼,並添加了工作流程的錯誤消息。 – 2012-02-20 09:14:37

+0

@MaksMatsveyeu - 我已經添加了源代碼,對於錯過這個關閉的道歉,並提前感謝您的幫助 – Luke 2012-02-20 09:47:12

回答

相關問題