Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

any way to query entity name by entity type code?

Posted on by Microsoft Employee

Hello, I have a design that generically supports different types of entities. This design involves passing an ObjectTypeCode parameter as part of a request to a manager class.

So, for example, if a request with ObjectTypeCode = 112 is passed to the manager class then the manager class treats the request as an incident request because CRM defines an incident as having ObjectTypeCode 112.

I'm having problems using a QueryExpression for this. When I try to query "entity" or "entityview" through a QueryExpression, CRM returns the following error message:

The entity with a name = '[entityname]' was not found in the MetadataCache

Do you have any recommendations that I can follow to query an entity name by ObjectTypeCode?

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: any way to query entity name by entity type code?

    I decided to go with a parameter of entity name instead of object type code.  Since QueryExpressions use entity name, using entity name as a parameter seems like a reasonable approach, especially given the fact that custom entity object type codes are not guaranteed to be the same across environments.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: any way to query entity name by entity type code?

    That's insightful.  Thanks Guido.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: any way to query entity name by entity type code?

    yes you can pass entity name in the object type code

    get object type code

    var objectTypeCode = Xrm.Page.context.getQueryStringParameters().etc

    window.open("/DNS/notes/edit.aspx?hideDesc=1&pId=" + recordid + "&pType="+objectTypeCode+"", "", "width=500,height=200");

    object type code by entity name

    var selectQuery = "AnnotationSet?$select=AnnotationId&$filter=IsDocument eq true and ObjectTypeCode eq 'dns_match' and ObjectId/Id eq guid'" + objectid + "'";

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,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans