Dynamic 365 SetStateDynamicEntity I was working on a plugin that has to fire when record gets deactivated or activated. To handle this scenario I had to use SetStateDynamicEntity Message. When it comes to the plug-in code you have to look for “ EntityMoniker” as an EntityReferece on the context. Here is a snippet of code: if (context.InputParameters.Contains( "EntityMoniker" ) && context.InputParameters[ "EntityMoniker" ] is EntityReference ) To retrieve the State and Status values you can use the following code OptionSetValue state = ( OptionSetValue )context.InputParameters[ "State" ]; OptionSetValue status = ( OptionSetValue )context.InputParameters[ "Status" ]; Here is where things got interesting, if you are like me you are expecting the right value for the status “ statucode field value”, instead I started getting Status=-1; Which is not a valid value for the OptionSet field. Which made ...