SQL for dettecting CRM Attribute mapping missmatch

By Panayiotis Panayiotou at December 13, 2010 09:48
Filed Under: Dynamic CRM Adventures

 About a week ago I had to transfer some customizations from a production system to a VM to update our development environment with the last customer changes and was facing an issue with mappings between attributes of different sizes (and especially) the target attribute being smaller than the source attribute. As the number of customizations were large I had to automate the process by writting a SQL statement to find the differences:

SELECT EntityMap.SourceEntityName,

            SourceAttributeName,

        SRC.Name,

        SourceLenght = CASE WHEN SRC.AttributeLogicalTypeId = 'Text' then SRC.Length / 2 ELSE SRC.Length END,

        SRC.AttributeLogicalTypeId,

            EntityMap.TargetEntityName,

        TargetAttributeName,

        TRG.Name,

        TargetLenght = CASE WHEN TRG.AttributeLogicalTypeId = 'Text' then TRG.Length / 2 ELSE TRG.Length END,

        TRG.AttributeLogicalTypeId

  FROM AttributeMapBase

       JOIN EntityMap ON (AttributeMapBase.EntityMapId = EntityMap.EntityMapId)

       LEFT OUTER JOIN EntityView SRCE ON (SRCE.Name = EntityMap.SourceEntityName)

       LEFT OUTER JOIN AttributeView SRC ON (SRC.EntityId = SRCE.EntityId AND SRC.Name = SourceAttributeName)

       LEFT OUTER JOIN EntityView SRCT ON (SRCT.Name = EntityMap.TargetEntityName)

       LEFT OUTER JOIN AttributeView TRG ON (TRG.EntityId = SRCT.EntityId  AND TRG.Name = TargetAttributeName)

  where EntityMap.SourceEntityName = 'lead' AND

        EntityMap.TargetEntityName = 'contact' AND

        (TRG.Length <> SRC.Length)

 

This is a list of the complete requirements by MS for CRM mappings
-           Both attributes must be of the same type and the same format.
-           The length of the target attribute must be equal to or greater than the length of the source attribute.
-           The target attribute cannot already be mapped to another attribute.
-           The source attribute must be visible on the form.
-           The target attribute must be a field that a user can enter data into.
-           If the attributes are picklists, the integer values for each option should be identical
-           Address ID values cannot be mapped.

 I also found very helpful the following link:

 http://rc.crm.dynamics.com/rc/regcont/en_us/op/articles/5-entitycustomizations.aspx

 

Tag cloud

    RecentPosts