2
我有一個silverlight應用程序,我正在使用它作爲CRM 2015的Web資源,我使用this教程來使用異步並等待關鍵字。我可以成功檢索實體。但是,我試圖創建實體到CRM中,但出於某種原因,我收到錯誤消息「單元ID缺失」。組織服務創建實體返回「單元ID缺失」
我嘗試只是爲了測試一個非常簡單的實體創建和仍然相同的結果,這裏是我的代碼:
Guid ProductCategoryGuid = new Guid(mytextblock.Tag.ToString());
Money Amount= new Money();
Amount.Value = Decimal.Parse(mytextblock.Text);
EntityReference Opportunity = new EntityReference();
Opportunity.Id = OpportunityGuid;
Opportunity.LogicalName = "opportunity";
EntityReference Product = new EntityReference();
Product.Id = SelectedProductGuid;
Product.LogicalName = "product";
EntityReference ProductCategory = new EntityReference();
ProductCategory.Id = ProductCategoryGuid;
ProductCategory.LogicalName = "new_productcategory";
Entity OpportunityProduct = new Entity();
OpportunityProduct.LogicalName = "opportunityproduct";
OpportunityProduct["new_productcategory"] = ProductCategory;
OpportunityProduct["productid"] = Product;
OpportunityProduct["opportunityid"] = Opportunity;
OpportunityProduct["baseamount"] = Amount;
await service.Create(OpportunityProduct);
編輯:
我不知道是否有幫助,但我用提琴手調試我的應用程序,我得到這個錯誤:「單位ID是缺少」。
opportunityproduct需要其他屬性,如opportunitytiyid和productid(如果它不是寫入產品) –
@GuidoPreite我已更新我的問題與我一直在測試的原始代碼一樣,這也包含產品和機會。我確定爲所有實體提供的Guids存在於crm中,因爲它們最初是從它們中檢索出來的。 – user3340627
使用簡單的控制檯應用程序嘗試代碼,如果控制檯應用程序工作意味着問題出現在Silverlight中 –