组织服务创建实体 returns "The unit id is missing"

Organization Service Create Entity returns "The unit id is missing"

我有一个 silverlight 应用程序,我将其用作 CRM 2015 的 Web 资源,我已经使用 this 教程来使用 async 和 await 关键字。我可以成功检索实体。但是,我试图在 CRM 中创建实体,但由于某种原因,我收到了错误消息 "The unit id is missing"。

我尝试了一个非常简单的实体创建只是为了测试,结果还是一样,这是我的代码:

 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);

编辑:

我不确定这是否有帮助,但我使用 Fiddler 调试我的应用程序并收到此错误:“单元 ID 丢失”。

原来我没有为机会产品添加 uom id。我检索了我在 OpportunityProduct 中引用的产品的 defaultuomid,然后创建成功完成