Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

How to get the type of a field in Dynamics using Xrm.Utility.getEntityMetadata

Posted on by 5

Hello,

I'm trying to use Xrm.Utility.getEntityMetadata to get the type of an entity field in CRM, but I'm not getting it. In the documentation it says that when executing the command, a collection of attributes is returned and it has the type of the attribute.

https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/xrm-utility/getentitymetadata

        Xrm.Utility.getEntityMetadata('account', 'name').then(
            function(entityMetadata){
                console.log(entityMetadata);
                console.log(entityMetadata.Attibutes['name'].AttributeType);
            }
        )

When I run the code above, several properties are returned, but I don't know how to get the type of field I want. Could someone please give me an example of how to get this property?

7446.entityMetadata.PNG

  • Suggested answer
    Afantonio Profile Picture
    Afantonio 5 on at
    RE: How to get the type of a field in Dynamics using Xrm.Utility.getEntityMetadata

    Hi Kokulan,

    Thank you very much for the answer, it was exactly what I needed.

  • Suggested answer
    Kokulan Profile Picture
    Kokulan 18,048 on at
    RE: How to get the type of a field in Dynamics using Xrm.Utility.getEntityMetadata

    Hi

    Please make sure you pass the attributes in an array as shown below

    Xrm.Utility.getEntityMetadata('account', ['createdon', 'name'])

    And when you get the results, you can access it using a few different ways, the following is one of them

    pastedimage1591910828649v1.png

    Thanks

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