Hi,
When trying to update an Entity by using LINQ query provider in Dynamics CRM 201 this way:
regardingOpportunity.PriceLevelId = new EntityReference(PriceLevel.EntityLogicalName, rateCard.Id);
MyXrmServiceContext.Update(regardingOpportunity);
.. I came across the following exception:
EntityState must be set to null, Created (for Create message) or Changed (for Update message)
Pretty odd but in my case I get it to work by just using method UpdateObject instead of Update:
regardingOpportunity.PriceLevelId = new EntityReference(PriceLevel.EntityLogicalName, rateCard.Id);
MyXrmServiceContext.UpdateObject(regardingOpportunity);
MyXrmServiceContext.SaveChanges();
Apparently (honestly not sure), by using UpdateObject record is marked as modified and that allows to save it later.
Hope it helps to save somebody else’s time.
PP [twitter: @pabloperalta]
UruIT Dynamix | Excellence in Dynamics CRM Nearshoring Services.


Like
Report
*This post is locked for comments