Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Getting Picklist values from D365 OData Metadata API

(0) ShareShare
ReportReport
Posted on by 10

Hello Q&A Forum,

I have a question about the Dynamics 365 metadata API. We are trying to get values from a Picklist attribute of a Dynamics 365 Entity. For example when we describe the attributes of an Account using the following URL

https://{D365-instance}/api/data/v9.0/EntityDefinitions(LogicalName='account')/Attributes

We see that one 'Account' attribute 'ShippingMethodCode' is a PickList type, and when we look in our Dynamics 365 we see that the dropdown for Shipping Method has DHL, FedEx, Will Call, etc. What we are looking for is an API that will retrieve the possible values to Picklist type attributes. Here is one URL we have tried so far

https://{D365-instance}/api/data/v9.0/EntityDefinitions(LogicalName='account')/Attributes(LogicalName='shippingmethodcode')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$expand=GlobalOptionSet($select=Options)

This API gave us some options but didn't line up with the options that we saw on the dynamics UI.

Let me know if you require any more, background on our problem

  • Ben smith Profile Picture
    Ben smith 10 on at
    RE: Getting Picklist values from D365 OData Metadata API

    Mehdi El Amri,

    Not a problem! Thank you for following up. I think I should make it clear that we are approaching finding these PickList values without a specific instance of an account. I was wondering is it possible to find out all of the shipping methods from the attributes of contacts API from just looking at the Account Attributes API call? Take for example the "Lookup" Type.

    Problem - We need to find all of the "Lookup" type fields for "customerid" in an "incident" entity.

    Solution following the proceeding steps

    1. When looking up all the attributes of an "incident" you will come across "customerid" attribute, which is defined as a "LookUp" Value
    2. From looking at the "Targets" section and see that "contact" and "account" are the entities that customer ID points to

      Screen-Shot-2021_2D00_04_2D00_05-at-4.19.05-PM.png

    3. Then we look up the contact definition and see that the "EntitySetName" is "contacts" which gives us the Entity Set we need to look up to get all the possible instances of contacts.

      Screen-Shot-2021_2D00_04_2D00_05-at-4.49.15-PM.png

    4. Finally, we look up the contacts API and see all the contacts.
    5. Pulling this all together, we can associate all the contacts from step 4 with the customer ID from step 1

    New Problem - We need to find all of the "Picklist" type fields for "shippingmethodcode" in an "account" entity.

    Does this hold of other PickList type attributes on other entities?

  • Suggested answer
    meelamri Profile Picture
    meelamri 13,212 User Group Leader on at
    RE: Getting Picklist values from D365 OData Metadata API

    Hello Benjamin,

    sorry for the delay, I just got your back.

    "CustomerAddress" Entity known as "Address" is a very special entity on the CRM that stores address and shipping information for accounts and contacts only.

    "address1_shippingmethodcode" contact field is also stored on "CustomerAddress" Entity. 

    Example: 

    ContactId: {05ACDC5F-8681-EB11-B1AB-000D3A468D62}

    pastedimage1617375202411v1.png

    The shipping method for address 1 is DHL (code 2). This information is also stored in the CustomerAddress entity: 
    https://{D365-instance}/api/data/v9.2/customeraddresses?$filter=(_parentid_value eq 05acdc5f-8681-eb11-b1ab-000d3a468d62 and addressnumber eq 1)

    pastedimage1617375543773v2.png

    How did I get the right request? 

    I used the stringmap entity which stores all the metadata fields of type optionset used in the CRM. Please check this Url:
    https://{D365-instance}/api/data/v9.2/stringmaps?$select=attributevalue,attributename,value,objecttypecode&$filter=(Microsoft.Dynamics.CRM.EqualUserLanguage(PropertyName='langid') and attributename eq 'ShippingMethodCode')

    pastedimage1617375633225v3.png

  • Ben smith Profile Picture
    Ben smith 10 on at
    RE: Getting Picklist values from D365 OData Metadata API

    @Fernando Acevedo - I don't understand your answers. Can you please try again

    @Mehdi El Amri - Can you please elaborate on your answer. This is what I'm looking for but I don't know how you got to that answer. See my other post.

    Thanks for both of your responses to my question

  • Suggested answer
    Fernando Acevedo Profile Picture
    Fernando Acevedo 65 on at
    RE: Getting Picklist values from D365 OData Metadata API
    [quote user="Ben smith"]

    Hello Q&A Forum,

    I have a question about the Dynamics 365 metadata API. We are trying to get values from a Picklist attribute of a Dynamics 365 Entity. For example when we describe the attributes of an Account using the following URL

    https://{D365-instance}/api/data/v9.0/EntityDefinitions(LogicalName='account')/Attributes

    We see that one 'Account' attribute 'ShippingMethodCode' is a PickList type, and when we look in our Dynamics 365 we see that the dropdown for Shipping Method has DHL, FedEx, Will Call, etc. What we are looking for is an API that will retrieve the possible values to Picklist type attributes. Here is one URL we have tried so far

    https://{D365-instance}/api/data/v9.0/EntityDefinitions(LogicalName='account')/Attributes(LogicalName='shippingmethodcode')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$expand=GlobalOptionSet($select=Options)

    This API gave us some options but didn't line up with the options that we saw on the dynamics UI.

    Let me know if you require any more, background on our problem

    [/quote]
  • Suggested answer
    Fernando Acevedo Profile Picture
    Fernando Acevedo 65 on at
    RE: Getting Picklist values from D365 OData Metadata API
    [quote user="Ben smith"]

    Thank you for the fast response, my apologies that I could not get to it quicker I have a few questions and observations

    1. I see you are using the 'customeraddress' entity, when the original URL was using the 'account' entity, can you expand on why you are using this entity?
    2. Is there a way to tie the 'customeraddress' entity to the 'account' entity using the 'shippingmethodcode' attribute?
    3. Are there any extra headers that might be needed to maybe tease out this relationship? I know that OData Annotations can help give users context on some Metadata API calls
    [/quote]
  • Suggested answer
    Fernando Acevedo Profile Picture
    Fernando Acevedo 65 on at
    RE: Getting Picklist values from D365 OData Metadata API
    [quote user="Ben smith"]

    Thank you for the fast response, my apologies that I could not get to it quicker I have a few questions and observations

    1. I see you are using the 'customeraddress' entity, when the original URL was using the 'account' entity, can you expand on why you are using this entity?
    2. Is there a way to tie the 'customeraddress' entity to the 'account' entity using the 'shippingmethodcode' attribute?
    3. Are there any extra headers that might be needed to maybe tease out this relationship? I know that OData Annotations can help give users context on some Metadata API calls
    [/quote]
  • Ben smith Profile Picture
    Ben smith 10 on at
    RE: Getting Picklist values from D365 OData Metadata API

    Thank you for the fast response, my apologies that I could not get to it quicker I have a few questions and observations

    1. I see you are using the 'customeraddress' entity, when the original URL was using the 'account' entity, can you expand on why you are using this entity?
    2. Is there a way to tie the 'customeraddress' entity to the 'account' entity using the 'shippingmethodcode' attribute?
    3. Are there any extra headers that might be needed to maybe tease out this relationship? I know that OData Annotations can help give users context on some Metadata API calls
  • Suggested answer
    meelamri Profile Picture
    meelamri 13,212 User Group Leader on at
    RE: Getting Picklist values from D365 OData Metadata API

    Hello, 

    Please check this URL: 

    https://{D365-instance}/api/data/v9.0/EntityDefinitions(LogicalName='customeraddress')/Attributes(LogicalName='shippingmethodcode')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$expand=GlobalOptionSet($select=Options)

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,407 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans