In plugin when i will invoice contract, contractLine is set some fields.
My source.
var res = from ser in ServiceContext.CreateQuery("contractdetail") where (ser["contractid"].Equals(strContractId)) select ser; foreach (Entity cdi in res) { Money valor = new Money(20); if (cdi.Attributes.Contains("price")) cdi["price"] = valor; else cdi.Attributes.Add("price", valor); if (cdi.Attributes.Contains("net")) cdi["net"] = valor; else cdi.Attributes.Add("net", valor); ServiceContext.UpdateObject(cdi); } //Here happen the error. ServiceContext.SaveChanges();
Remarks:
context.ParentContext.MessageName "SetStateDynamicEntity"
draft to invoice or active.
It's work in CRM plugin 2015!!!
Error:
The target state is invalid. The target state may not exist or the system does not allow changing to the target state from the current state.
*This post is locked for comments