Monday, 14 March 2016

Get ObjectTypeCode of the entity in CRM

Here is the C# code to get the OjbectTypeCode of the entity in CRM.
private static int GetEntityTypeCode(string EntityName)
      RetrieveEntityRequest request = new RetrieveEntityRequest();
      request.LogicalName = EntityName;
      // Retrieve the MetaData.
      RetrieveEntityResponse response = (RetrieveEntityResponse)crmService.Execute(request);
      int objecttypecode = response.EntityMetadata.ObjectTypeCode.Value;
      return objecttypecode;
Hope this helps.
Happy CRM'ing


No comments:

Post a Comment