How to Find the Entity Type Code
[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
- In the Navigation Pane for the Web application, click Settings, click Customization, and then click Customize Entities.
- Open the Bank Account entity, and then click Forms and Views.
- Click Form, and then on the Actions toolbar, click More Actions, and then click Edit.
- Click Form Properties.
- Click onLoad, and then click Edit.
- 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
- On the Preview menu, click Create Form.
- Your script is executed when the form loads.
- To close the Preview form, on the File menu, click Close.
- Click OK to close the Form Properties dialog box.
- Click Close to close the form, discarding your changes because you do not want to see this alert all the time.
- Click Close to close the entity.
© 2010 Microsoft Corporation. All rights reserved.