Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

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

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

  • Suggested answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 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

  • Suggested answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 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
    Community Member Profile Picture
    Community Member Microsoft Employee 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'

  • JayeshAC Profile Picture
    JayeshAC 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
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 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.

  • Suggested answer
    ashlega Profile Picture
    ashlega 34,475 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
    Gopalan Bhuvanesh Profile Picture
    Gopalan Bhuvanesh 11,397 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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans