Home › Dynamics 365 Customer Engagement (CRM) › Understanding StateCode, StatusCode, Status and Status Reason in Dynamics 365
Dynamics 365 Customer Engagement (CRM) · Feb 5, 2018 · 2 MIN READ

Understanding StateCode, StatusCode, Status and Status Reason in Dynamics 365

In Dynamics 365, entities contain the fields StateCode and StatusCode. If we create a new entity, we can see the statecode (display name Status) and statuscode (display name Status Reason) fields are automatically created:

We can also see the types of these fields are Status and Status Reason respectively.

Let’s look at the Status field. We can see it is of type Status, but we do not see any values associated with it:

The Status Reason is of type Status Reason and has one value called Active:

We can rename and delete Active if we want to:

We can also add our own values:

If we look in Advanced Find at our new entity and filter on Status, we can see there are 2 options – Active and Inactive:

With Status Reason, we get Active, Inactive and In Progress (the new one we added):

The Status Reason is a special field, in that in the toolbar we see Edit Status Reason Transitions:

You can read more about those on my post here.

Let’s look at other entities in the system. First, Accounts. This has 2 states, Active and Inactive:

And 2 status reasons:

For Opportunities, status is Won, Lost, Open:

And Status Reason has several options (Accepted, Canceled etc):

The Opportunity Status contains the data type:

And Status Reasons we can create/edit/delete:

Note if we look for statecode or statuscode in global option sets, we will not see it:

To get these option set labels, we can use the Web API and access EntityDefinitions.

For state:

https://yourorg.api.crm.dynamics.com/api/data/v9.1/EntityDefinitions(LogicalName=’opportunity’)/Attributes/Microsoft.Dynamics.CRM.StateAttributeMetadata?$expand=OptionSet

Here we can see Won, Lost, Open states:

For status:

https://yourorg.api.crm.dynamics.com/api/data/v9.1/EntityDefinitions(LogicalName=’opportunity’)/Attributes/Microsoft.Dynamics.CRM.StatusAttributeMetadata?$expand=OptionSet

Here we can see the Open for Bidding label in the query:

 

Carl de Souza
Keep learning. Keep building.

Explore AI, agents & Microsoft technology.

I share practical ideas, tutorials, and videos about AI, AI agents, Microsoft technologies, and the Power Platform.

Subscribe on YouTube →
Carl de Souza Enterprise Architect at Microsoft · AI Technology Expert

One Response to Understanding StateCode, StatusCode, Status and Status Reason in Dynamics 365

  1. Do you know how to get the Status as input in a custom workflow activity? I tried to use OptionSetValue and it didn’t work

Leave a Reply

Your email address will not be published. Required fields are marked *

Carl de Souza
KEEP LEARNING. KEEP BUILDING.

Explore AI, agents & Microsoft technology.

I share practical ideas, tutorials, and videos about AI, AI agents, Microsoft technologies, and the Power Platform.