Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 general forum

Decoding Drop-down options to int/string values

Posted on by 27

I added a new field to the account entity. and I'm creating new accounts using the API and want to be able to provide the text and not the table value.

<Property Name="new_industry" Type="Edm.Int32"/>

Basically I want to provide "Airline / Aviation" and the get back "100000002" or just be able to provide "Airline / Aviation" and the CRM will convert it automatically in the POST requests. 

"value": [

{
"name": "Test with 1111",
"new_industry": 100000002
}
]

0361.Capture.PNG

  • cloflyMao Profile Picture
    cloflyMao 25,198 on at
    RE: Decoding Drop-down options to int/string values

    Hi maorlv,

    Optionset value is restrict to integer type thus we can only set it with whole number when creating/updating records with option set field.

    However, you can get/retrieve the text/label with formatted value, please take these threads as reference if they could meet your demand:

    http://himbap.com/blog/?p=2077

    https://community.dynamics.com/crm/f/microsoft-dynamics-crm-forum/246368/javascript-to-get-optionset-text-from-value

    https://community.dynamics.com/crm/f/microsoft-dynamics-crm-forum/270412/web-api---how-to-retrieve-statecodes-and-statuscodes

    https://community.dynamics.com/crm/f/microsoft-dynamics-crm-forum/276535/javascript-using-odata-and-should-show-value-of-the-optionset-industrycode

    In addition, you could paste following script and execute it in Console tab in developer tool in your CRM tab to quickly get an optionsetItem array of an optionset field and view each item value and text:

    Xrm.Page.ui.controls.get("new_industry").getAttribute().getOptions();

    pastedimage1564496284722v1.png

    Regards,

    Clofly

  • Suggested answer
    StefanS365 Profile Picture
    StefanS365 3,573 Most Valuable Professional on at
    RE: Decoding Drop-down options to int/string values

    Hi there,

    You need a custom entity with conversion records to be able to do this.

    See for more info:

    community.dynamics.com/.../how-to-use-dynamics-optionset-labels-within-powerbi

  • apa Profile Picture
    apa 8,282 on at
    RE: Decoding Drop-down options to int/string values

    I have moved this post to the D365 General Forum from PSA.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans