Dynamics Crm: Get metadata for statuscode/statecode mapping

后端 未结 3 883
没有蜡笔的小新
没有蜡笔的小新 2021-02-13 20:03

In Dynamics CRM 2011, on the Incident entity, the \"Status Reason\" optionset (aka statuscode) is related to the \"Status\" optionset (aka statecode)

e.g. see this scree

3条回答
  •  醉梦人生
    2021-02-13 20:41

    Here is how you can get it by querying the database

    SELECT distinct e.LogicalName as entity,
          smState.Value AS stateCode,
          smstate.AttributeValue,
          smStatus.Value AS [statuscode/statusreason],
          smStatus.AttributeValue
    FROM StatusMap sm
         JOIN Entity e ON sm.ObjectTypeCode = e.ObjectTypeCode
         JOIN StringMap smState ON smState.AttributeValue = sm.State
                               AND smState.ObjectTypeCode = e.ObjectTypeCode
                               AND smState.AttributeName = 'StateCode'
         JOIN StringMap smStatus ON smStatus.AttributeValue = sm.Status
                                AND smStatus.ObjectTypeCode = e.ObjectTypeCode
                                AND smStatus.AttributeName = 'StatusCode'
    WHERE  e.LogicalName in ('lead')
    ORDER BY e.LogicalName,
          smState.AttributeValue,
          smStatus.AttributeValue;
    

提交回复
热议问题