Reputation: 740
Is there anyway on client side in Dynamics CRM 2011 from JavaScript to retrieve Entity Logical Name by Object Type Code?
Example: Object Type Code = 1, Logical Name is Account
Upvotes: 2
Views: 1759
Reputation: 1
There's a super easy way.
Using Chrome, and in your CRM site( basically anywhere,) hit F12 go to console, and type:
Mscrm.EntityPropUtil.EntityTypeName2CodeMap
You will see the full list(as picture below) of the EntityTypeName and their Type Code(including your customized entities!)
Upvotes: 0
Reputation: 17562
Alternatively don't use the object type code at all. Sort of depends on what your exact usage is, but usually you can get straight to the entity name.
For example, Xrm.Page.data.entity.getEntityName()
returns the name of the current entity.
Upvotes: 1
Reputation: 3664
This is unsupported, but it does what you want:
function getLogicalNameFromTypeCode(typeCode) {
return Object.keys(Mscrm.EntityPropUtil.EntityTypeName2CodeMap).filter(function(key) {
return Mscrm.EntityPropUtil.EntityTypeName2CodeMap[key] === typeCode;
})[0];
}
Usage:
getLogicalNameFromTypeCode(1); // 'account'
Upvotes: 3