title: Dynamics Crm: Get metadata for statuscode/statecode mapping
body: <p>In Dynamics CRM 2011, on the Incident entity, the "Status Reason" optionset (aka statuscode) is related to the "Status" optionset (aka statecode)</p>
  
  <p>e.g. see this screenshot</p>
  
  <p><img src="https://i.stack.imgur.com/sLqQ9.png" alt="screenshot of CRM field options"></p>
  
  <p>When I use the API to retrieve the Status Reason optionset, like so:</p>
  
  <pre><code>        RetrieveAttributeRequest attributeRequest = new RetrieveAttributeRequest
          {
              EntityLogicalName = "incident",
              LogicalName = "statuscode",
              RetrieveAsIfPublished = true
          };
          RetrieveAttributeResponse attributeResponse = (RetrieveAttributeResponse)serv.Execute(attributeRequest);
          AttributeMetadata attrMetadata = (AttributeMetadata)attributeResponse.AttributeMetadata;
          StatusAttributeMetadata statusMetadata = (StatusAttributeMetadata)attrMetadata;
          var dict = new Dictionary&lt;int?, string&gt;();
          foreach (OptionMetadata optionMeta in statusMetadata.OptionSet.Options)
          {
              dict.Add(optionMeta.Value, optionMeta.Label.UserLocalizedLabel.Label);
          }
  </code></pre>
  
  <p>It works in that I get the whole list of "Status Reason" (statuscode) options. However, I dont get any info about which "Status Reason" (statuscode) options relate to which "Status" (statecode) options.</p>
  
  <p>How do I get that information?</p>