Skip to content
Microsoft Dynamics 365 CRM Tips and Tricks
By Inogic
  • Blogs
  • D365 Apps
  • Inogic
  • D365 / Power Platform Services
  • Maplytics Docs
  • D365 Apps Docs
    • Omnichannel Apps
      • WhatsApp4Dynamics
      • TextSMS4Dynamics
      • LiveChat4Dynamics
    • File and Storage Managment
      • Attach2Dynamics
      • SharePoint Security Sync
    • Visualization Apps
      • Map My Relationships
      • Kanban Board
      • Business Process Checklist
    • Productivity Apps
      • Click2Clone
      • Click2Export
      • Undo2Restore
      • Lead Assignment and Distribution Automation
      • Alerts4Dynamics
      • Translate4Dynamics
      • Subscription Recurring Billing Management
    • User Adoption Apps
      • DeDupeD
      • User Adoption Monitor
      • Gamifics365
    • Integration Apps
      • Marketing4Dynamics
      • InoLink

How to retrieve entity metadata using Xrm.Utility.getEntityMetadata()

By Inogic | October 27, 2020
0 Comment

Introduction

Currently, we need to create http requests to retrieve the metadata of the entity or attributes of any entity. But now, Dynamics 365 introduced a Web API method i.e Xrm.Utility.getEntityMetadata() which helps you retrieve any entity metadata easily without creating any http requests. Please find below two examples to understand this method in detail:

1. Retrieve whole entity metadata

Let’s take one example, we want to check if the current entity is activity entity or not. For this query, you can simply use Xrm.Utility.getEntityMetadata, you need to just pass the entity logical name of the entity which you want to retrieve the metadata for, as shown below:

Xrm.Utility.getEntityMetadata(“account”, []).then(

function(entityMetadata){

//check for entity metadata

If(entityMetadata!=undefined){

//declare one flag which indicate current entity is activity entity

var isActivityEntity = false;

//check for IsActivity attribute

if (entityMetadata.IsActivity != undefined) {

//check current entity is activity entity using IsActivity attribute

if (entityMetadata.IsActivity == true) {

//set flag to true as current entity is Activity entity

isActivityEntity = true;

} else {

//set flag to false as current entity is not Activity entity

isActivityEntity = true;

}

}

}

}, function(e){

//error

alert(e.error.message);

});

Note: We pass the second parameter is empty [] to getEntityMetadata method because in the above example we need to retrieve all metadata of the Account entity.

After running the below code, we will get all the metadata of that entity such as logical name, entity set name, as shown in the below screenshot.

2. Retrieve metadata of selected attribute of any entity

Now, we want to retrieve any attribute metadata of any entity that you want in Dynamics 365. Let’s take one example; we want to retrieve metadata of the industry field of Account entity using the getEntityMetadata method. In this scenario, you need to pass those entity names and attributes list for which you want to retrieve metadata, as shown below.

Xrm.Utility.getEntityMetadata(“account”, [“industrycode”]).then(

function (entityMetadata) {

//check for attribute entity metadata

if (entityMetadata != undefined && entityMetadata.Attributes != undefined && entityMetadata.Attributes._collection != undefined) {

//check for industry type option set

if (entityMetadata.Attributes._collection[“industrycode”]) {

//get option set data

var industryCodeOptionSetData = entityMetadata.Attributes._collection[“industrycode”].OptionSet;

}

}

}, function(e){

//error call back

alert(e.error.message);

});

After running the above code you will get all options data in the industry field Option Set, as shown in the below screenshot:

How to retrieve entity metadata using Xrm.Utility.getEntityMetadata

Conclusion

With help of Xrm.Utility.getEntityMetadata() method you can retrieve metadata of any entity or metadata of any attributes of that entity, you no longer need to create an http request to achieve this.

Category: Dynamics 365 Dynamics 365 v9 Dynamics CRM Dynamics CRM 2016 Tags: Dynamics 365 CRM, Dynamics CRM, Entity, metadata, Retrive metadata, XRM, Xrm.Utility
Post navigation
← Daily, Weekly, Monthly or Annually – Schedule and Automate Bills Generation in Dynamics 365 CRM/Power Apps with Recurring Billing Manager! Match the theme of Dynamics 365 App in Power Apps Control Framework – Part 1 →

Follow Us!

Follow Us on FacebookFollow Us on TwitterFollow Us on LinkedInFollow Us on YouTubeFollow Us on InstagramFollow Us on E-mailFollow Us on Docs

Blog Series

  • Power Apps – Model Driven Apps
  • Power Apps – Canvas App
  • Power Pages
  • Power Automate
  • Power BI
  • AI Builder
  • Copilot
  • Azure OpenAI
  • Microsoft Teams
  • Dynamics 365 for Field Service

Recent Innovations

Translate Dynamics 365 Data in Real-Time using Azure AI Translator with our New App!

Summer 2025 Dynamics 365 Maps Release: Smarter Routing, Azure Maps, Canvas Apps & More!

How to Create Mailchimp Email Campaigns Directly from Dynamics 365 CRM!

Detect and Merge Dynamics 365 CRM Duplicate Records with New DeDupeD Features!

SharePoint Metadata – Enhance document searchability in Dynamics 365 CRM integration!

WhatsApp, Text SMS, and Live Chat Integration – Dynamics 365 Omnichannel suite by Inogic!

Recent Posts

  • Role-Based Access Control for Document Security in Dynamics 365 CRM!
  • How to Create and Modify a Segment in Customer Insights – Journeys Using the Web API
  • Dynamics 365 WhatsApp Integration: Trigger vs Segment Customer Journeys – Explained!
  • Add Process Mining Report in Power BI Workspace
  • Webinar: Copilot Agents in Action: Document Reading, Response Generation, and Email Drafting!

Archives

SiteLock
Copyright © 2025 Inogic. All Rights Reserved
Iconic One Theme | Powered by Wordpress