CRM Version 9.0.12.4 On Premise
To reproduce:
1. Find an Account that is the Customer on an expired contract
2. Using the SDK, retrieve the account record, change any field on the record - e.g. set the "Description" field to "test"
3. Update the record via the SDK
4. You get a "Contract state invalid error"
... something like this:
var account = orgContext.Retrieve("account", id, new ColumnSet(true)).ToEntity<Account>();
account.Description = "test";
orgContext.Update(account);
5. If you update the field using the CRM UI (Account form) then you do NOT get an error (which is unsettling!)
We have a server that is on version 9.0.2.3034, and when we run the same update code against that environment, we do not see the error - so the bug was introduced between 9.0.2.3034 and 9.0.12.4
Additionally, if we change the relationship type of the Contract's Customer-Account related property from "Parental" to "Cascade" the error stops happening, so it seems to have something to do with the parental relationship between the account record and the contract record - it should not be trying to update expired contracts.
Thanks!