Saturday, April 08, 2017

Dynamics CRM–Status to Status Reason Mapping (statecode to statuscode)

SELECT distinct e.LogicalName as entity,
      smState.Value AS [State/StateCode],
       smstate.AttributeValue as stateCode,
       smStatus.Value AS [statusReason/statusCode],
       smStatus.AttributeValue as statusCode
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  1=1
and e.IsCustomEntity = 0
and e.LogicalName in ('lead','account','contact','opportunity')
ORDER BY e.LogicalName,
       smState.AttributeValue,
         smStatus.AttributeValue;

https://docs.google.com/spreadsheets/d/1PnfHNqUdKQ54rJyeRolOeCZVk73zcvo-0qmtN3MF-sc/pubhtml

No comments:

Post a Comment

Remember, if you want me to respond to your comment, then you need to use a Google/OpenID account to leave the comment.