statecode And statuscode
Several adapter objects have common fields. Some objects have a statecode field and a statuscode field. In the Microsoft Dynamics 365 user interface, these relate to Status and Status Reason:
- statecode — Typically
shown as the "status" in the Dynamics 365 application. The values allowed
for this field vary from object to object and cannot be customized.
Only transitions defined as "valid" in the Dynamics 365 business rules are allowed. The adapter allows transitions that require multiple steps, such as 1 to 2, then 2 to 3. Each object has a default initial statecode.
Your Dynamics 365 version determines how this field is updated:
- Version 7.1 and later — Update operations modify this field.
- Version 7.0 and earlier — If you set this value and an insert, update, or upsert operation does not leave the object in that state, the adapter changes the object’s state to this value. This field can be updated in the Workbench.
- statuscode — Typically
shown as the "Status Reason" in the Dynamics 365 application. The values
allowed for this field vary from object to object and can be customized
for most objects. However, a default statuscode exists for each statecode.
This field can be updated in the Workbench. If there is no state change, setting this field updates the current statuscode for the object. If there is a statechange, setting this field specifies the statuscode associated with the new state.
Statuscode values are defined to correspond to a specific statecode value. For example, if a lead has a statecode = 0 (open), it can have a statuscode of 1 (new) or 2 (contacted). If the lead has a statecode = 2 (disqualified), the allowed statuscode values include 4 (lost), 5 (cannot contact), as well as others.
Dynamics 365 accepts only statuscodes that are valid for the current or newly assigned statecode. If you change the statecode using the statecode field and you don't set a statuscode, the default statuscode value for the new statecode is assigned.
- vfObjectState — A virtual field that functions like the statecode field. This field is marked as a hidden field and is only included for backward compatibility with previous adapter releases.
Review the Field Properties dialog box in the Workbench for a complete list of allowed values for any of the three fields described above. If the statuscode values are customized, the custom values are shown.