How to get ObjectTypeCode of an entity using JavaScript in D365/MSCRM ?

Spread the Knowledge...

Getting EntityTypeCode/ObjectTypeCode of any entity in MSCRM through JavaScript is always been a difficult job.

There is a unique ObjectTypeCode for every entity in CRM.

If you are using On-Premise CRM org then there is a simple query that you can execute on organization database to get all the ObjectTypeCodes and the basic details of the entity.

SELECT * FROM entityview
ORDER BY ObjectTypeCode

Below are some approaches to retrieve ObjectTypeCode of entity in MSCRM:

  1. Retrieving ObjectTypeCode through javascript.(its good method but still unsupported)
Mscrm.EntityPropUtil.EntityTypeName2CodeMap 
  1. Other ways to retrieve ObjectTypeCode through javascript for perticular entity.
Mscrm.EntityPropUtil.EntityTypeName2CodeMap.account

OR

Mscrm.EntityPropUtil.EntityTypeName2CodeMap["account"]

OR

Mscrm.EntityPropUtil.EntityTypeName2CodeMap.account

Check out the list of ObjectTypeCode in order to make this finding easier:

EntitySchemaNameObjectTypeCodeOwnershipType
Account1UserOwned
Contact2UserOwned
Opportunity3UserOwned
Lead4UserOwned
Annotation5UserOwned
BusinessUnitMap6None
Owner7None
SystemUser8BusinessOwned
Team9BusinessOwned
BusinessUnit10BusinessOwned
PrincipalObjectAccess11None
RolePrivileges12None
SystemUserLicenses13None
SystemUserPrincipals14None
SystemUserRoles15None
AccountLeads16None
ContactInvoices17None
ContactQuotes18None
ContactOrders19None
ServiceContractContacts20None
ProductSalesLiterature21None
ContactLeads22None
TeamMembership23None
LeadCompetitors24None
OpportunityCompetitors25None
CompetitorSalesLiterature26None
LeadProduct27None
RoleTemplatePrivileges28None
Subscription29None
FilterTemplate30None
PrivilegeObjectTypeCodes31None
SalesProcessInstance32BusinessOwned
SubscriptionSyncInfo33None
SubscriptionTrackingDeletedObject35None
ClientUpdate36None
SubscriptionManuallyTrackedObject37None
SharedObjectsForRead39None
TeamRoles40None
PrincipalEntityMap41None
SystemUserBusinessUnitEntityMap42None
PrincipalAttributeAccessMap43None
PrincipalObjectAttributeAccess44OrganizationOwned
SubscriptionStatisticsOffline45None
SubscriptionStatisticsOutlook46None
SubscriptionSyncEntryOffline47None
SubscriptionSyncEntryOutlook48None
Position50OrganizationOwned
SystemUserManagerMap51None
UserSearchFacet52None
PrincipalObjectAccessReadSnapshot90None
RecordCountSnapshot91None
TeamTemplate92None
SocialProfile99UserOwned
Incident112UserOwned
ChildIncidentCount113None
Competitor123OrganizationOwned
DocumentIndex126None
KbArticle127OrganizationOwned
Subject129OrganizationOwned
BusinessUnitNewsArticle132OrganizationOwned
ActivityParty135None
UserSettings150BusinessOwned
NewProcess950OrganizationOwned
TranslationProcess951OrganizationOwned
PhoneToCaseProcess952OrganizationOwned
OpportunitySalesProcess953OrganizationOwned
LeadToOpportunitySalesProcess954OrganizationOwned
ExpiredProcess955OrganizationOwned
ActivityMimeAttachment1001None
Attachment1002None
InternalAddress1003None
CompetitorAddress1004None
CompetitorProduct1006None
ImageDescriptor1007None
Contract1010UserOwned
ContractDetail1011None
Discount1013None
KbArticleTemplate1016OrganizationOwned
LeadAddress1017None
Organization1019OrganizationOwned
OrganizationUI1021None
PriceLevel1022OrganizationOwned
Privilege1023None
Product1024OrganizationOwned
ProductAssociation1025OrganizationOwned
ProductPriceLevel1026None
ProductSubstitute1028OrganizationOwned
SystemForm1030OrganizationOwned
UserForm1031UserOwned
Role1036BusinessOwned
RoleTemplate1037None
SalesLiterature1038OrganizationOwned
SavedQuery1039OrganizationOwned
StringMap1043OrganizationOwned
DynamicProperty1048OrganizationOwned
DynamicPropertyOptionSetItem1049OrganizationOwned
UoM1055None
UoMSchedule1056OrganizationOwned
SalesLiteratureItem1070None
CustomerAddress1071None
SubscriptionClients1072None
StatusMap1075OrganizationOwned
DiscountType1080OrganizationOwned
KbArticleComment1082None
OpportunityProduct1083None
Quote1084UserOwned
QuoteDetail1085None
UserFiscalCalendar1086None
SalesOrder1088UserOwned
SalesOrderDetail1089None
Invoice1090UserOwned
InvoiceDetail1091None
AuthorizationServer1094OrganizationOwned
PartnerApplication1095OrganizationOwned
SavedQueryVisualization1111OrganizationOwned
UserQueryVisualization1112UserOwned
RibbonTabToCommandMap1113OrganizationOwned
RibbonContextGroup1115OrganizationOwned
RibbonCommand1116OrganizationOwned
RibbonRule1117OrganizationOwned
RibbonCustomization1120OrganizationOwned
RibbonDiff1130OrganizationOwned
ReplicationBacklog1140None
Characteristic1141UserOwned
RatingValue1142UserOwned
RatingModel1144UserOwned
BookableResourceBooking1145UserOwned
BookableResourceBookingHeader1146UserOwned
BookableResourceCategory1147UserOwned
BookableResourceCharacteristic1148UserOwned
BookableResourceCategoryAssn1149UserOwned
BookableResource1150UserOwned
BookableResourceGroup1151UserOwned
BookingStatus1152UserOwned
RecommendedDocument1189OrganizationOwned
FieldSecurityProfile1200OrganizationOwned
FieldPermission1201None
SystemUserProfiles1202None
TeamProfiles1203None
QueueMembership1213None
ChannelPropertyGroup1234OrganizationOwned
DynamicPropertyAssociation1235OrganizationOwned
ChannelProperty1236OrganizationOwned
SocialInsightsConfiguration1300None
SavedOrgInsightsConfiguration1309OrganizationOwned
DynamicPropertyInstance1333UserOwned
SyncAttributeMappingProfile1400OrganizationOwned
SyncAttributeMapping1401None
SystemUserSyncMappingProfiles1402None
TeamSyncAttributeMappingProfiles1403None
PrincipalSyncAttributeMap1404OrganizationOwned
AnnualFiscalCalendar2000None
SemiAnnualFiscalCalendar2001None
QuarterlyFiscalCalendar2002None
MonthlyFiscalCalendar2003None
FixedMonthlyFiscalCalendar2004None
Template2010UserOwned
ContractTemplate2011OrganizationOwned
UnresolvedAddress2012None
Territory2013OrganizationOwned
Theme2015OrganizationOwned
UserMapping2016OrganizationOwned
Queue2020UserOwned
QueueItemCount2023None
QueueMemberCount2024None
License2027None
QueueItem2029None
UserEntityUISettings2500UserOwned
UserEntityInstanceData2501UserOwned
IntegrationStatus3000OrganizationOwned
ChannelAccessProfile3005UserOwned
ExternalParty3008UserOwned
ConnectionRole3231OrganizationOwned
ConnectionRoleAssociation3232None
ConnectionRoleObjectTypeCode3233None
Connection3234UserOwned
Equipment4000BusinessOwned
Service4001OrganizationOwned
Resource4002BusinessOwned
Calendar4003BusinessOwned
CalendarRule4004None
ResourceGroup4005BusinessOwned
ResourceSpec4006BusinessOwned
ConstraintBasedGroup4007BusinessOwned
Site4009OrganizationOwned
ResourceGroupExpansion4010None
InterProcessLock4011None
EmailHash4023None
DisplayStringMap4101None
DisplayString4102OrganizationOwned
Notification4110None
ExchangeSyncIdMapping4120UserOwned
ActivityPointer4200UserOwned
Appointment4201UserOwned
Email4202UserOwned
Fax4204UserOwned
IncidentResolution4206UserOwned
Letter4207UserOwned
OpportunityClose4208UserOwned
OrderClose4209UserOwned
PhoneCall4210UserOwned
QuoteClose4211UserOwned
Task4212UserOwned
ServiceAppointment4214UserOwned
Commitment4215None
SocialActivity4216UserOwned
UntrackedEmail4220UserOwned
UserQuery4230UserOwned
MetadataDifference4231None
BusinessDataLocalizedLabel4232None
RecurrenceRule4250UserOwned
RecurringAppointmentMaster4251UserOwned
EmailSearch4299None
List4300UserOwned
ListMember4301None
Campaign4400UserOwned
CampaignResponse4401UserOwned
CampaignActivity4402UserOwned
CampaignItem4403None
CampaignActivityItem4404None
BulkOperationLog4405None
BulkOperation4406UserOwned
Import4410UserOwned
ImportMap4411UserOwned
ImportFile4412UserOwned
ImportData4413UserOwned
DuplicateRule4414UserOwned
DuplicateRecord4415None
DuplicateRuleCondition4416None
ColumnMapping4417None
PickListMapping4418None
LookUpMapping4419None
OwnerMapping4420None
BookableResourceBookingExchangeSyncIdMapping4421UserOwned
ImportLog4423UserOwned
BulkDeleteOperation4424None
BulkDeleteFailure4425None
TransformationMapping4426None
TransformationParameterMapping4427None
ImportEntityMapping4428None
DataPerformance4450OrganizationOwned
OfficeDocument4490None
RelationshipRole4500OrganizationOwned
RelationshipRoleMap4501None
CustomerRelationship4502UserOwned
CustomerOpportunityRole4503UserOwned
EntitlementTemplateProducts4545None
Audit4567None
EntityMap4600OrganizationOwned
AttributeMap4601OrganizationOwned
PluginType4602OrganizationOwned
PluginTypeStatistic4603OrganizationOwned
PluginAssembly4605OrganizationOwned
SdkMessage4606OrganizationOwned
SdkMessageFilter4607OrganizationOwned
SdkMessageProcessingStep4608OrganizationOwned
SdkMessageRequest4609OrganizationOwned
SdkMessageResponse4610OrganizationOwned
SdkMessageResponseField4611OrganizationOwned
SdkMessagePair4613OrganizationOwned
SdkMessageRequestField4614OrganizationOwned
SdkMessageProcessingStepImage4615OrganizationOwned
SdkMessageProcessingStepSecureConfig4616OrganizationOwned
ServiceEndpoint4618OrganizationOwned
PluginTraceLog4619OrganizationOwned
AsyncOperation4700UserOwned
WorkflowWaitSubscription4702None
Workflow4703UserOwned
WorkflowDependency4704None
IsvConfig4705OrganizationOwned
WorkflowLog4706None
ApplicationFile4707OrganizationOwned
OrganizationStatistic4708None
SiteMap4709OrganizationOwned
ProcessSession4710UserOwned
ProcessTrigger4712None
ProcessStage4724None
BusinessProcessFlowInstance4725None
WebWizard4800OrganizationOwned
WizardPage4802OrganizationOwned
WizardAccessPrivilege4803OrganizationOwned
TimeZoneDefinition4810None
TimeZoneRule4811None
TimeZoneLocalizedName4812None
EntitlementProducts6363None
SystemApplicationMetadata7000None
UserApplicationMetadata7001UserOwned
Solution7100OrganizationOwned
Publisher7101OrganizationOwned
PublisherAddress7102None
SolutionComponent7103None
Dependency7105None
DependencyNode7106None
InvalidDependency7107None
DependencyFeature7108None
EntitlementContacts7272None
Post8000OrganizationOwned
PostRole8001OrganizationOwned
PostRegarding8002None
PostFollow8003UserOwned
PostComment8005OrganizationOwned
PostLike8006OrganizationOwned
TraceLog8050OrganizationOwned
TraceAssociation8051None
TraceRegarding8052None
RoutingRule8181UserOwned
RoutingRuleItem8199None
HierarchyRule8840OrganizationOwned
AppModule9006OrganizationOwned
AppModuleComponent9007None
AppModuleRoles9009None
Report9100UserOwned
ReportEntity9101None
ReportCategory9102None
ReportVisibility9103None
ReportLink9104None
TransactionCurrency9105OrganizationOwned
MailMergeTemplate9106UserOwned
ImportJob9107OrganizationOwned
LocalConfigStore9201None
ConvertRule9300UserOwned
ConvertRuleItem9301None
WebResource9333OrganizationOwned
ChannelAccessProfileRule9400UserOwned
ChannelAccessProfileRuleItem9401None
ChannelAccessProfileEntityAccessLevel9404None
SharePointSite9502UserOwned
SharePointDocument9507UserOwned
SharePointDocumentLocation9508UserOwned
SharePointData9509OrganizationOwned
RollupProperties9510None
RollupJob9511None
Goal9600UserOwned
GoalRollupQuery9602UserOwned
Metric9603OrganizationOwned
RollupField9604None
EmailServerProfile9605UserOwned
Mailbox9606UserOwned
MailboxStatistics9607None
MailboxTrackingFolder9608UserOwned
SqlEncryptionAudit9613None
ComplexControl9650OrganizationOwned
OrgInsightsMetric9699OrganizationOwned
Entitlement9700UserOwned
EntitlementChannel9701None
EntitlementTemplate9702OrganizationOwned
EntitlementTemplateChannel9703None
SLA9750UserOwned
SLAItem9751None
SLAKPIInstance9752UserOwned
CustomControl9753OrganizationOwned
CustomControlResource9754OrganizationOwned
CustomControlDefaultConfig9755OrganizationOwned
MobileOfflineProfile9866OrganizationOwned
MobileOfflineProfileItem9867OrganizationOwned
MobileOfflineProfileItemAssociation9868OrganizationOwned
SyncError9869UserOwned
MultiEntitySearch9910None
MultiEntitySearchEntities9911None
HierarchySecurityConfiguration9919None
KnowledgeBaseRecord9930OrganizationOwned
IncidentKnowledgeBaseRecord9931None
TimeStampDateMapping9932None
RecommendationModel9933OrganizationOwned
RecommendationModelMapping9934OrganizationOwned
RecommendationModelVersion9935OrganizationOwned
AzureServiceConnection9936OrganizationOwned
RecommendationModelVersionHistory9937OrganizationOwned
RecommendationCache9938None
DocumentTemplate9940OrganizationOwned
PersonalDocumentTemplate9941UserOwned
TopicModelConfiguration9942OrganizationOwned
TopicModelExecutionHistory9943OrganizationOwned
TopicModel9944OrganizationOwned
TextAnalyticsEntityMapping9945OrganizationOwned
TopicHistory9946None
KnowledgeSearchModel9947OrganizationOwned
Topic9948None
AdvancedSimilarityRule9949OrganizationOwned
OfficeGraphDocument9950OrganizationOwned
SimilarityRule9951OrganizationOwned
KnowledgeArticle9953UserOwned
KnowledgeArticleIncident9954None
KnowledgeArticleViews9955None
LanguageLocale9957OrganizationOwned
Feedback9958UserOwned
Category9959UserOwned
KnowledgeArticlesCategories9960None
DelveActionHub9961OrganizationOwned
ActionCard9962UserOwned
ActionCardUserState9968None
ActionCardUserSettings9973UserOwned
CardType9983None
InteractionForEmail9986UserOwned
ExternalPartyItem9987None
EmailSignature9997UserOwned
msdyn_PostAlbum10000UserOwned
msdyn_PostConfig10001OrganizationOwned
msdyn_PostRuleConfig10002OrganizationOwned
msdyn_wallsavedquery10003OrganizationOwned
msdyn_wallsavedqueryusersettings10004UserOwned

Hope you find it helpful!!!


Spread the Knowledge...