This is a rehash of Michaël Hompus’ post https://blog.hompus.nl/2015/05/28/entity-type-code-using-javascript-only/ to help me remember this very useful trick.
Note that the scripts described in this post are unsupported.
In JavaScript, use Mscrm.EntityPropUtil.EntityTypeName2CodeMap to retrieve the entity type code for a given entity type name, e.g.:
Mscrm.EntityPropUtil.EntityTypeName2CodeMap.new_application //returns 10008
Use Mscrm.EntityPropUtil.EntityLogicalNameToLocalizedNameMap to retrieve the entity display name for a given entity type name, e.g.:
Mscrm.EntityPropUtil.EntityLogicalNameToLocalizedNameMap.new_application //returns Credit Application
Depending on how your script was loaded, Mscrm may be null, in which case try looking for it under the parent object instead, i.e. parent.Mscrm.EntityPropUtil…
There is also Xrm.Internal.getEntityCode, Xrm.Internal.getEntityDisplayName and Xrm.Internal.getEntityName which is little easier. Still unsupported though.
Good to know! Thanks Natraj!