I have a silverlight application which i'm using as a web resource for CRM 2015, I have used this tutorial to use async and await keywords. I can retrieve entities successfully. However, I'm trying to create entities into the CRM but for some reason I'm getting the error message "The unit id is missing".
I tried a very simple entity creation just for testing and still the same result, here is my code:
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);
EDIT:
I'm not sure if that helps, but I used Fiddler to debug my application and I got this Error: "The unit id is missing".
It turns out I hadn't added the uom id for the opportunity product. I retrieved the defaultuomid of the product i'm referring to in the OpportunityProduct and then creation was completed successfully