Quick one! Have you ever tried, or are you currently trying to get statuscodemetadata programatically from your Dynamics organisation? e.g. the Status Reason on your Lead or Contact entity.

I mean these values, with their label and underlying value:

You can do so, using the Web API .

However, status reason requires a different message to your usual option set.

Here are some examples

1. This example gets the labels and values of options on an option set called mediasource on the lead entity:

GET [Organization URI]/api/data/v8.2/EntityDefinitions(LogicalName='lead')/Attributes(LogicalName='mediasource')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$expand=GlobalOptionSet($select=Options)

Of course for your scenario, you'll need to alter the HTTP request. Replace lead with the name of your entity and mediasourcewith the name of the option set you're trying to retrieve.

Remember you can test your HTTP request by sending it in your browser as https://yourcrmorganisation.crm11.dynamics.com/api/data/...

This request returns the following response:

{    
    "@odata.type":"#Microsoft.Dynamics.CRM.OptionSetMetadata","Options":[
      {
        "Value":1,"Label":{
          "LocalizedLabels":[
            {
              "Label":"Email","LanguageCode":1033,"IsManaged":false,"MetadataId":"691137dd-4970-e711-80fd-70106faae7f1","HasChanged":null
            }
          ]
        }
      },{
        "Value":2,"Label":{
          "LocalizedLabels":[
            {
              "Label":"Phone","LanguageCode":1033,"IsManaged":false,"MetadataId":"6c1137dd-4970-e711-80fd-70106faae7f1","HasChanged":null
            }
          ]
        }
      }
    ]    
}

2. Now if you want to get the value for statuscode which is also an option set, you have to use StatusAttributeMetadata rather than PicklistAttributeMetadata.

This example gets the labels and values of options on the status reason field on the lead entity:

GET [Organization URI]/api/data/v8.2/EntityDefinitions(LogicalName='lead')/Attributes/Microsoft.Dynamics.CRM.StatusAttributeMetadata?$select=LogicalName&$expand=OptionSet($select=Options)

Which returns the following response:

{
    "OptionSet": {
        "Options": [
            {
                "@odata.type": "#Microsoft.Dynamics.CRM.StatusOptionMetadata",
                "Value": 1,
                "Label": {
                    "LocalizedLabels": [
                        {
                            "Label": "New"
                        }
                    ]
                }
            },
            {
                "@odata.type": "#Microsoft.Dynamics.CRM.StatusOptionMetadata",
                "Value": 2,
                "Label": {
                    "LocalizedLabels": [
                        {
                            "Label": "Being Worked On"
                        }
                    ]
                }
            }
        ]
    }
}

Again, in your specific HTTP request, replace lead with the name of your entity.