Microsoft Dynamics CRM and Microsoft Dynamics 365 provide indicators throughout the application to help us know whether the records that we are seeking are available to work on or have already been deactivated (resolved, won, cancelled or no longer needed). These indicators are set using the Status and Status Reason fields, which are also linked together.
The Status indicator (statecode attribute) states whether a particular record is still active. In most records in CRM the Status indicator only has two values or Active and Inactive, but in some places throughout the system, it can have some different values such as Open, Completed and Canceled as in the case of an email record, or Active, Closed, Paid and Canceled as in the case of an invoice record. The Status is usually visible at the bottom left of the screen, showing the Active or Inactive status. When the status is inactive, the status bar at the bottom of the screen is displayed in yellow, and the bottom right will display the text Read-Only (as shown below).
The Status Reason provides additional details about the status of the particular record. In the screenshot below, the status of the record is Disqualified (Inactive), which is set when the lead is completed as Won or Lost. The disqualified status has four status reason options which include Lost, Cannot Contact, No Longer Interested and Canceled. When deactivating a record and disqualifying in this case, the application will let us choose the Status reason of why the record is being made Inactive.
The following screenshot shows how the Disqualify the lead record, which will provide the available options as part of the Disqualify drop down:
Most entities, howerver, especially custom developed entities will not have that feature, and when you click on the Deactivate button, the Deactivate popup will appear asking for the confirmation to deactivate the record. If a record that you seek to Deactivate has multiple Status Reasons, you will have the option to select the status reason during the Deactivation phase (as shown in the image below):
Additional Status Reasons can be added to the Status Reason field in your Solution or the Default Solution. Note that the Status reason field is similar to an option set field, so the numbering sequences will be similar. If you add a new status reason, the new status reason will be similar to 100,000,001 (or something else depending on your publisher prefix). These numbers however, cannot be modified when creating a status reason from within the Status Reason window
If you would like to create a new Status Reason using a different number (such as 3 for example), you can do that by using the following C# request message:
InsertStatusValueRequest insertStatusValueRequest = new InsertStatusValueRequest { AttributeLogicalName = "statuscode", EntityLogicalName = entityLogicalName, Label = new Label(label, 1033), Value = statusCode, // integer value of current State Code StateCode = stateCode // integer value of new Status Code }; int _insertedStatusValue = ((InsertStatusValueResponse)service.Execute(insertStatusValueRequest)).NewOptionValue;
The link below contains the Default Status (statecode) and Status Reason (statuscode) values for all System CRM entities: