Deactivate a record to any custom or system entity in Microsoft Dynamics CRM 4.0 programmatically in a plugin using dynamic entity changing state code and status code | Mohamed Mostafa's Blog
activate and deactivate records programmatically using CRM API/SDK. The function allows you to set the state code (statuscode field) as active or inactive and set the status code field value (status code or status reason) to any value from the values you specificy in your Microsoft Dynamics CRM organization. For example, if you set statuscode Cancelled as a reason, you need to know what integer this status reason represents and pass this value to this function.