web
You’re offline. This is a read only version of the page.
close
Skip to main content
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

I have the same question (0)
  • Suggested answer
    meelamri Profile Picture
    13,216 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)

  • Ben smith Profile Picture
    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
    Fernando Acevedo Profile Picture
    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
    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
    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]
  • Ben smith Profile Picture
    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
    meelamri Profile Picture
    13,216 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
    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?

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 365 | Integration, Dataverse, and general topics

#1
#ManoVerse Profile Picture

#ManoVerse 101

#2
Siv Sagar Profile Picture

Siv Sagar 93 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 66 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans