Having recently upgraded our ISV Solution from both CRM 2013 and CR 2015 to CRM 2016, we started to receive the following error, when one our our Pre-Operation(Create) Plugin Steps fired;
“Changing state attributes is not allowed in create stage 20 plugins”
Basically, the plugin on create of a new Entity records was setting the “Status Reason” based on the Status Reason of a “parental related” entity’s Status Reason.
Now this code (below) works completely fine in both CRM 2013 and 2015, however causes issues in CRM 2016.
//DD Contract - Active entity.Attributes.Add("statuscode", new OptionSetValue(1));
A search of the web resulted in little or no information about this issue in CRM 2016, so my approach was to move the specific code that set the Status Reason to a “Post-Operation” and use SetStateRequest.
The down-side of this, is the extra operation step that is required to achieve the same result, which previously was achievable in a single step.