Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

OData query for optionset

Posted on by 2,397

Hi, I am trying to return optionset text by OData query in C#, it always returns the value, how can I get the text?

*This post is locked for comments

  • Suggested answer
    LeoAlt Profile Picture
    LeoAlt 16,329 on at
    RE: OData query for optionset

    Hi partner,

    You could refer to this request header according to SDK.

    GET [Organization URI]/api/data/v9.0/EntityDefinitions(LogicalName='account')/Attributes(5967e7cc-afbb-4c10-bf7e-e7ef430c52be)/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$expand=OptionSet HTTP/1.1  
    Accept: application/json  
    Content-Type: application/json; charset=utf-8  
    OData-MaxVersion: 4.0  
    OData-Version: 4.0

    community27.png 

    Hope it helps.

    Best Regards

    Leo

  • Suggested answer
    Arun Vinoth Profile Picture
    Arun Vinoth 11,613 on at
    RE: OData query for optionset

    Have you started writing the code? Show your code. Js or c# or php or java - when you want something from web api request you have to set the header.

    Use odata.include-annotations header for your purpose.

  • sdnd2000 Profile Picture
    sdnd2000 2,397 on at
    RE: OData query for optionset

    Is that only for javascript?

  • Suggested answer
    Arun Vinoth Profile Picture
    Arun Vinoth 11,613 on at
    RE: OData query for optionset

    If you are using webapi, then you can.

    stackoverflow.com/.../7920473

  • sdnd2000 Profile Picture
    sdnd2000 2,397 on at
    RE: OData query for optionset

    no way to do it through web api?

  • Suggested answer
    Arun Vinoth Profile Picture
    Arun Vinoth 11,613 on at
    RE: OData query for optionset

    You can query the metadata to pull the label for picklist value: nishantrana.me/.../sample-code-to-get-label-and-value-for-optionset-in-crm

    Read my answer in SO for enumerator concept:  stackoverflow.com/.../7920473

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