When we have to get the object type code for an entity normally what we can do is using the JavaScript function for the same in CRM 2011. The sample code for the same will be as follows,
var objectTypeCode= Xrm.Page.context.getQueryStringParameters().etc;
Above code should return the object type code for the respective entity.
Another way to get the object code for an entity is using the SQL query from the CRM DB. This can be achieved using below query.
SELECT Name,LogicalName,ObjectTypeCode
FROM
EntityView
ORDER BY ObjectTypeCode
If you want to get the object type code via C# below is the snippet for the same,
RetrieveEntityRequest entityRequest = new RetrieveEntityRequest();
entityRequest.LogicalName = entityName;
RetrieveEntityResponse entityResponse = (RetrieveEntityResponse)service.Execute(entityRequest);
objectTypeCode = entityResponse.EntityMetadata.ObjectTypeCode.Value;
For your reference the result for the above query is listed below.
var objectTypeCode= Xrm.Page.context.getQueryStringParameters().etc;
Above code should return the object type code for the respective entity.
Another way to get the object code for an entity is using the SQL query from the CRM DB. This can be achieved using below query.
SELECT Name,LogicalName,ObjectTypeCode
FROM
EntityView
ORDER BY ObjectTypeCode
If you want to get the object type code via C# below is the snippet for the same,
RetrieveEntityRequest entityRequest = new RetrieveEntityRequest();
entityRequest.LogicalName = entityName;
RetrieveEntityResponse entityResponse = (RetrieveEntityResponse)service.Execute(entityRequest);
objectTypeCode = entityResponse.EntityMetadata.ObjectTypeCode.Value;
For your reference the result for the above query is listed below.
| Name | Logical Name | Object Type Code |
| Account | account | 1 |
| Contact | contact | 2 |
| Opportunity | opportunity | 3 |
| Lead | lead | 4 |
| Annotation | annotation | 5 |
| BusinessUnitMap | businessunitmap | 6 |
| Owner | owner | 7 |
| SystemUser | systemuser | 8 |
| Team | team | 9 |
| BusinessUnit | businessunit | 10 |
| PrincipalObjectAccess | principalobjectaccess | 11 |
| RolePrivileges | roleprivileges | 12 |
| SystemUserLicenses | systemuserlicenses | 13 |
| SystemUserPrincipals | systemuserprincipals | 14 |
| SystemUserRoles | systemuserroles | 15 |
| AccountLeads | accountleads | 16 |
| ContactInvoices | contactinvoices | 17 |
| ContactQuotes | contactquotes | 18 |
| ContactOrders | contactorders | 19 |
| ServiceContractContacts | servicecontractcontacts | 20 |
| ProductSalesLiterature | productsalesliterature | 21 |
| ContactLeads | contactleads | 22 |
| TeamMembership | teammembership | 23 |
| LeadCompetitors | leadcompetitors | 24 |
| OpportunityCompetitors | opportunitycompetitors | 25 |
| CompetitorSalesLiterature | competitorsalesliterature | 26 |
| LeadProduct | leadproduct | 27 |
| RoleTemplatePrivileges | roletemplateprivileges | 28 |
| Subscription | subscription | 29 |
| FilterTemplate | filtertemplate | 30 |
| PrivilegeObjectTypeCodes | privilegeobjecttypecodes | 31 |
| SalesProcessInstance | salesprocessinstance | 32 |
| SubscriptionSyncInfo | subscriptionsyncinfo | 33 |
| SubscriptionTrackingDeletedObject | subscriptiontrackingdeletedobject | 35 |
| ClientUpdate | clientupdate | 36 |
| SubscriptionManuallyTrackedObject | subscriptionmanuallytrackedobject | 37 |
| TeamRoles | teamroles | 40 |
| PrincipalEntityMap | principalentitymap | 41 |
| SystemUserBusinessUnitEntityMap | systemuserbusinessunitentitymap | 42 |
| PrincipalAttributeAccessMap | principalattributeaccessmap | 43 |
| PrincipalObjectAttributeAccess | principalobjectattributeaccess | 44 |
| PrincipalObjectAccessReadSnapshot | principalobjectaccessreadsnapshot | 90 |
| RecordCountSnapshot | recordcountsnapshot | 91 |
| Incident | incident | 112 |
| Competitor | competitor | 123 |
| DocumentIndex | documentindex | 126 |
| KbArticle | kbarticle | 127 |
| Subject | subject | 129 |
| BusinessUnitNewsArticle | businessunitnewsarticle | 132 |
| ActivityParty | activityparty | 135 |
| UserSettings | usersettings | 150 |
| ActivityMimeAttachment | activitymimeattachment | 1001 |
| Attachment | attachment | 1002 |
| InternalAddress | internaladdress | 1003 |
| CompetitorAddress | competitoraddress | 1004 |
| CompetitorProduct | competitorproduct | 1006 |
| Contract | contract | 1010 |
| ContractDetail | contractdetail | 1011 |
| Discount | discount | 1013 |
| KbArticleTemplate | kbarticletemplate | 1016 |
| LeadAddress | leadaddress | 1017 |
| Organization | organization | 1019 |
| OrganizationUI | organizationui | 1021 |
| PriceLevel | pricelevel | 1022 |
| Privilege | privilege | 1023 |
| Product | product | 1024 |
| ProductAssociation | productassociation | 1025 |
| ProductPriceLevel | productpricelevel | 1026 |
| ProductSubstitute | productsubstitute | 1028 |
| SystemForm | systemform | 1030 |
| UserForm | userform | 1031 |
| Role | role | 1036 |
| RoleTemplate | roletemplate | 1037 |
| SalesLiterature | salesliterature | 1038 |
| SavedQuery | savedquery | 1039 |
| StringMap | stringmap | 1043 |
| UoM | uom | 1055 |
| UoMSchedule | uomschedule | 1056 |
| SalesLiteratureItem | salesliteratureitem | 1070 |
| CustomerAddress | customeraddress | 1071 |
| SubscriptionClients | subscriptionclients | 1072 |
| StatusMap | statusmap | 1075 |
| DiscountType | discounttype | 1080 |
| KbArticleComment | kbarticlecomment | 1082 |
| OpportunityProduct | opportunityproduct | 1083 |
| Quote | quote | 1084 |
| QuoteDetail | quotedetail | 1085 |
| UserFiscalCalendar | userfiscalcalendar | 1086 |
| SalesOrder | salesorder | 1088 |
| SalesOrderDetail | salesorderdetail | 1089 |
| Invoice | invoice | 1090 |
| InvoiceDetail | invoicedetail | 1091 |
| SavedQueryVisualization | savedqueryvisualization | 1111 |
| UserQueryVisualization | userqueryvisualization | 1112 |
| RibbonTabToCommandMap | ribbontabtocommandmap | 1113 |
| RibbonContextGroup | ribboncontextgroup | 1115 |
| RibbonCommand | ribboncommand | 1116 |
| RibbonRule | ribbonrule | 1117 |
| RibbonCustomization | ribboncustomization | 1120 |
| RibbonDiff | ribbondiff | 1130 |
| ReplicationBacklog | replicationbacklog | 1140 |
| FieldSecurityProfile | fieldsecurityprofile | 1200 |
| FieldPermission | fieldpermission | 1201 |
| SystemUserProfiles | systemuserprofiles | 1202 |
| TeamProfiles | teamprofiles | 1203 |
| AnnualFiscalCalendar | annualfiscalcalendar | 2000 |
| SemiAnnualFiscalCalendar | semiannualfiscalcalendar | 2001 |
| QuarterlyFiscalCalendar | quarterlyfiscalcalendar | 2002 |
| MonthlyFiscalCalendar | monthlyfiscalcalendar | 2003 |
| FixedMonthlyFiscalCalendar | fixedmonthlyfiscalcalendar | 2004 |
| Template | template | 2010 |
| ContractTemplate | contracttemplate | 2011 |
| UnresolvedAddress | unresolvedaddress | 2012 |
| Territory | territory | 2013 |
| Queue | queue | 2020 |
| License | license | 2027 |
| QueueItem | queueitem | 2029 |
| UserEntityUISettings | userentityuisettings | 2500 |
| UserEntityInstanceData | userentityinstancedata | 2501 |
| IntegrationStatus | integrationstatus | 3000 |
| ConnectionRole | connectionrole | 3231 |
| ConnectionRoleAssociation | connectionroleassociation | 3232 |
| ConnectionRoleObjectTypeCode | connectionroleobjecttypecode | 3233 |
| Connection | connection | 3234 |
| Equipment | equipment | 4000 |
| Service | service | 4001 |
| Resource | resource | 4002 |
| Calendar | calendar | 4003 |
| CalendarRule | calendarrule | 4004 |
| ResourceGroup | resourcegroup | 4005 |
| ResourceSpec | resourcespec | 4006 |
| ConstraintBasedGroup | constraintbasedgroup | 4007 |
| Site | site | 4009 |
| ResourceGroupExpansion | resourcegroupexpansion | 4010 |
| InterProcessLock | interprocesslock | 4011 |
| EmailHash | emailhash | 4023 |
| DisplayStringMap | displaystringmap | 4101 |
| DisplayString | displaystring | 4102 |
| Notification | notification | 4110 |
| ActivityPointer | activitypointer | 4200 |
| Appointment | appointment | 4201 |
| 4202 | ||
| Fax | fax | 4204 |
| IncidentResolution | incidentresolution | 4206 |
| Letter | letter | 4207 |
| OpportunityClose | opportunityclose | 4208 |
| OrderClose | orderclose | 4209 |
| PhoneCall | phonecall | 4210 |
| QuoteClose | quoteclose | 4211 |
| Task | task | 4212 |
| ServiceAppointment | serviceappointment | 4214 |
| Commitment | commitment | 4215 |
| UserQuery | userquery | 4230 |
| RecurrenceRule | recurrencerule | 4250 |
| RecurringAppointmentMaster | recurringappointmentmaster | 4251 |
| EmailSearch | emailsearch | 4299 |
| List | list | 4300 |
| ListMember | listmember | 4301 |
| Campaign | campaign | 4400 |
| CampaignResponse | campaignresponse | 4401 |
| CampaignActivity | campaignactivity | 4402 |
| CampaignItem | campaignitem | 4403 |
| CampaignActivityItem | campaignactivityitem | 4404 |
| BulkOperationLog | bulkoperationlog | 4405 |
| BulkOperation | bulkoperation | 4406 |
| Import | import | 4410 |
| ImportMap | importmap | 4411 |
| ImportFile | importfile | 4412 |
| ImportData | importdata | 4413 |
| DuplicateRule | duplicaterule | 4414 |
| DuplicateRecord | duplicaterecord | 4415 |
| DuplicateRuleCondition | duplicaterulecondition | 4416 |
| ColumnMapping | columnmapping | 4417 |
| PickListMapping | picklistmapping | 4418 |
| LookUpMapping | lookupmapping | 4419 |
| OwnerMapping | ownermapping | 4420 |
| ImportLog | importlog | 4423 |
| BulkDeleteOperation | bulkdeleteoperation | 4424 |
| BulkDeleteFailure | bulkdeletefailure | 4425 |
| TransformationMapping | transformationmapping | 4426 |
| TransformationParameterMapping | transformationparametermapping | 4427 |
| ImportEntityMapping | importentitymapping | 4428 |
| RelationshipRole | relationshiprole | 4500 |
| RelationshipRoleMap | relationshiprolemap | 4501 |
| CustomerRelationship | customerrelationship | 4502 |
| CustomerOpportunityRole | customeropportunityrole | 4503 |
| Audit | audit | 4567 |
| EntityMap | entitymap | 4600 |
| AttributeMap | attributemap | 4601 |
| PluginType | plugintype | 4602 |
| PluginTypeStatistic | plugintypestatistic | 4603 |
| PluginAssembly | pluginassembly | 4605 |
| SdkMessage | sdkmessage | 4606 |
| SdkMessageFilter | sdkmessagefilter | 4607 |
| SdkMessageProcessingStep | sdkmessageprocessingstep | 4608 |
| SdkMessageRequest | sdkmessagerequest | 4609 |
| SdkMessageResponse | sdkmessageresponse | 4610 |
| SdkMessageResponseField | sdkmessageresponsefield | 4611 |
| SdkMessagePair | sdkmessagepair | 4613 |
| SdkMessageRequestField | sdkmessagerequestfield | 4614 |
| SdkMessageProcessingStepImage | sdkmessageprocessingstepimage | 4615 |
| SdkMessageProcessingStepSecureConfig | sdkmessageprocessingstepsecureconfig | 4616 |
| ServiceEndpoint | serviceendpoint | 4618 |
| AsyncOperation | asyncoperation | 4700 |
| WorkflowWaitSubscription | workflowwaitsubscription | 4702 |
| Workflow | workflow | 4703 |
| WorkflowDependency | workflowdependency | 4704 |
| IsvConfig | isvconfig | 4705 |
| WorkflowLog | workflowlog | 4706 |
| ApplicationFile | applicationfile | 4707 |
| OrganizationStatistic | organizationstatistic | 4708 |
| SiteMap | sitemap | 4709 |
| ProcessSession | processsession | 4710 |
| WebWizard | webwizard | 4800 |
| WizardPage | wizardpage | 4802 |
| WizardAccessPrivilege | wizardaccessprivilege | 4803 |
| TimeZoneDefinition | timezonedefinition | 4810 |
| TimeZoneRule | timezonerule | 4811 |
| TimeZoneLocalizedName | timezonelocalizedname | 4812 |
| Solution | solution | 7100 |
| Publisher | publisher | 7101 |
| PublisherAddress | publisheraddress | 7102 |
| SolutionComponent | solutioncomponent | 7103 |
| Dependency | dependency | 7105 |
| DependencyNode | dependencynode | 7106 |
| InvalidDependency | invaliddependency | 7107 |
| Post | post | 8000 |
| PostRole | postrole | 8001 |
| PostRegarding | postregarding | 8002 |
| PostFollow | postfollow | 8003 |
| PostComment | postcomment | 8005 |
| PostLike | postlike | 8006 |
| Report | report | 9100 |
| ReportEntity | reportentity | 9101 |
| ReportCategory | reportcategory | 9102 |
| ReportVisibility | reportvisibility | 9103 |
| ReportLink | reportlink | 9104 |
| TransactionCurrency | transactioncurrency | 9105 |
| MailMergeTemplate | mailmergetemplate | 9106 |
| ImportJob | importjob | 9107 |
| WebResource | webresource | 9333 |
| SharePointSite | sharepointsite | 9502 |
| SharePointDocumentLocation | sharepointdocumentlocation | 9508 |
| Goal | goal | 9600 |
| GoalRollupQuery | goalrollupquery | 9602 |
| Metric | metric | 9603 |
| RollupField | rollupfield | 9604 |
| ComplexControl | complexcontrol | 9650 |
No comments:
Post a Comment