This documentation is archived and is not being maintained.

How to Find the Entity Type Code

banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Find the latest SDK documentation: CRM 2015 SDK

You can retrieve the type codes for all entities by using the RetrieveAllEntities message.

If you have an on-premise deployment, you can use the Metadata Browser to view the entities and their type codes for your organization. See Using the Metadata Browser.

Alternatively, you can use a simple OnLoad script to determine the type code for an entity. This is especially useful for determining the type code for a custom entity. This sample assumes that you have a custom entity called Bank Account and the schema name is new_bankaccount.

Add a Script to run when a form is loaded

  1. In the Navigation Pane for the Web application, click Settings, click Customization, and then click Customize Entities.
  2. Open the Bank Account entity, and then click Forms and Views.
  3. Click Form, and then on the Actions toolbar, click More Actions, and then click Edit.
  4. Click Form Properties.
  5. Click onLoad, and then click Edit.
  6. On the Details tab, select the Event is enabled check box to enable the event, and in the text box, enter the body of the script shown here.
    alert("This is the type code: " + crmForm.ObjectTypeCode);

Test your script

  1. On the Preview menu, click Create Form.
  2. Your script is executed when the form loads.
  3. To close the Preview form, on the File menu, click Close.
  4. Click OK to close the Form Properties dialog box.
  5. Click Close to close the form, discarding your changes because you do not want to see this alert all the time.
  6. Click Close to close the entity.

© 2010 Microsoft Corporation. All rights reserved.