web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Need Odata query in Javascript to get the Custom Entity ObjectTypeCode value.

(0) ShareShare
ReportReport
Posted on by 1,157

Hi All,

I want to use Odata query in Javascript to get the custom Entity ObjectTypeCode value.

i have tried Odata query with entityName =  EntityView but it seems that this entity is not retrieved through odata call.

Please suggest me the approach.

Thanks,

Jayesh

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Gopalan Bhuvanesh Profile Picture
    11,401 on at
    RE: Need Odata query in Javascript to get the Custom Entity ObjectTypeCode value.

    Hi

    You can use Web API

    https://<org root uri>/api/data/v8.2/EntityDefinitions(LogicalName='account')?$select=ObjectTypeCode

    Use any Web API JavaScript library.

    Please refer the following:

    community.dynamics.com/.../retrieve-metadata-using-name-in-web-api

  • Suggested answer
    ashlega Profile Picture
    34,477 on at
    RE: Need Odata query in Javascript to get the Custom Entity ObjectTypeCode value.

    Hi,

     you can try this WebApi query:

    <server url>/api/data/v8.2/EntityDefinitions?$select=LogicalName,ObjectTypeCode&$filter=LogicalName%20eq%20%27account%27

  • Suggested answer
    Nithya Gopinath Profile Picture
    on at
    RE: Need Odata query in Javascript to get the Custom Entity ObjectTypeCode value.

    Hi Jayesh,

    The following URL will give you the object type code of the custom entity.

    https://[Your Organisation URL]/api/data/v8.2/EntityDefinitions?$select=ObjectTypeCode&$filter=SchemaName eq 'entitySchemaName'

    Hope this helps.

  • JayeshAC Profile Picture
    1,157 on at
    RE: Need Odata query in Javascript to get the Custom Entity ObjectTypeCode value.

    Thanks for the comments.

    We are using CRM On-prem 2016 version and i guess the suggested Web API method is for CRMD365 Online env.

    I tried this as well but failed to get the entity metadata or objectTypeCode.

    Do we have any other supported method to retrieve the ObjectTypeCode of the entity?

  • Suggested answer
    Community Member Profile Picture
    6,118 on at
    RE: Need Odata query in Javascript to get the Custom Entity ObjectTypeCode value.

    Please change the version of api to 8.1 and try again.

    https://[Your Organisation URL]/api/data/v8.1/EntityDefinitions?$select=ObjectTypeCode&$filter=SchemaName eq 'entitySchemaName'

  • Suggested answer
    Nithya Gopinath Profile Picture
    on at
    RE: Need Odata query in Javascript to get the Custom Entity ObjectTypeCode value.

    Hi Jayesh,

    For Dynamics CRM 2016, the version number is 8.1. So replace v8.2 in my above thread with v8.1.

    https://[Your Organisation URL]/api/data/v8.1/EntityDefinitions?$select=ObjectTypeCode&$filter=SchemaName eq 'entitySchemaName'

    Hope this helps.

  • Suggested answer
    Nithya Gopinath Profile Picture
    on at
    RE: Need Odata query in Javascript to get the Custom Entity ObjectTypeCode value.

    Hi Jayesh,

    You could also get the Object Type Code of any entity in the CRM by using a SQL query.

    1. Go to SQL Server Management Studio

    2. Open the Database of your Organisation

    3. Execute the following query

    select ObjectTypeCode,* from entityview

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans