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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

ObjectType Code for a custom entity for Online CRM

(0) ShareShare
ReportReport
Posted on by

Hi ,

I have a requirement to get the object type code for a custom entity in Dynamics CRM online 2016 version. Can anyone help me how to get it through javascript?

*This post is locked for comments

I have the same question (0)
  • Guido Preite Profile Picture
    54,086 Moderator on at

    just curious, why you need the object type code? the logical name is not enough?

  • Community Member Profile Picture
    on at

    Hi Guido,

    I need to put it on my custom view JavaScript. Do you know how to achieve it?

  • Verified answer
    Guido Preite Profile Picture
    54,086 Moderator on at

    you will need to query the metadata, but you are with CRM 2016.

    Normally I will suggest the SOAP endpoint (example here mileyja.blogspot.com/.../how-to-retrieve-metadata-for-entity.html and the response contains the objecttypecode) but with CRM 2016 you should use the WebApi (example here msdn.microsoft.com/.../mt607522.aspx) but looks like the objectypecode is not returned (at least in their examples) you should check if you can get it using the new WebApi.

    However I don't know what you are trying to achieve with "custom view JavaScript" but you should rely on logicalnames, not objecttypecodes

    hope it helps

  • Verified answer
    Community Member Profile Picture
    on at

    Hi,

    Add a client global context to the page, if not exist in the page.

    After adding use below code.

    var objectTypeCode="";

    if (Mscrm.XrmInternal.getEntityCode != null && Mscrm.XrmInternal.getEntityCode != undefined)

        objectTypeCode = Mscrm.XrmInternal.getEntityCode("entityLogicalName");

    else

        objectTypeCode = Mscrm.XrmInternal.prototype.getEntityCode("entityLogicalName");

  • Verified answer
    tpeschat Profile Picture
    4,930 on at

    You could try:

    blog.hompus.nl/.../entity-type-code-using-javascript-only

    But that's an unsupported method

    br Thomas

  • Community Member Profile Picture
    on at

    Hi Laxman,

    How to add a client global context to the page?

  • Suggested answer
    Community Member Profile Picture
    on at

    if you provide your html page url i will suggest it

    For my Html Page, i used below path to add

     <script src="../../ClientGlobalContext.js.aspx" type="text/javascript"></script>

    This context is provided by Microsoft only in CRM.

    Thanks,

    Laxman P

    laxman7790@gmail.com.

  • Suggested answer
    Siddique mahsud Profile Picture
    11 on at

    We can get objectTypeCode by using webApi.. Following url will return all the custom entity LogicalName  and ObjectTypeCode:

    {organizational Url}/api/data/v8.2/EntityDefinitions?$select=LogicalName,ObjectTypeCode&$filter=ObjectTypeCode%20gt%209999

    Get Object Type Code for entities in Dynamics CRM

  • Premz Profile Picture
    50 on at

    This worked. Thank you Muhammad Siddique.

  • naZir Profile Picture
    850 on at

    thanks for the Answer. :)

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans