web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Retrieving Option Set Labels with Xrm.WebApi.retrieveRecord

(0) ShareShare
ReportReport
Posted on by

Hi All,

I all prior to introduction new Client API for D365 v9, 

request.setRequestHeader("Prefer", "odata.include-annotations=OData.Community.Display.V1.FormattedValue");

was used to include Formatted Values.

How can I use Xrm.WebApi.retrieveRecord so that it returns the FormattedValues as well.

Example,

I am calling the below code

Xrm.WebApi.retrieveRequest("new_title","C859A265-6262-E811-A970-000D3A18032D","?$select=new_name,new_titletype").then(
function success(result) 
{ 
var titletype= result["new_titletype@OData.Community.Display.V1.FormattedValue"];
 // perform operations on record retrieval 
},
function (error)
{
 console.log(error.message);
 // handle error conditions
});

Here, new_titletype is an optionset attribute. Let us say for this example , it is equal to, Value:864560002 Label: "Standard"

Now, Upon Execution of above, result["new_titletype@OData.Community.Display.V1.FormattedValue"] returns undefined instead of "Standard".

Kindly assist.

Regards,

Siddharth


*This post is locked for comments

I have the same question (0)
  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Siddharth ,

    I don't think anything wrong in your code, can you please try to debug your code to make sure result contains data .

    I would also suggest try with below code -

      function retrieveTitle() {
                try { 
                    Xrm.WebApi.retrieveRecord("new_title", "C859A265-6262-E811-A970-000D3A18032D", "?$select=new_name,new_titletype")
                        .then(function (data) {
                            retrieveTitleSuccess(data);
                        },
                         function (error) {
                             Xrm.Utility.alertDialog(error.message);
                         });
                } catch (e) {
                    Xrm.Utility.alertDialog (e.message);
                }
            }
     
            ///retrieve success
            function retrieveTitleSuccess(data) {   
                try {                
                    //optionset
                    var titletype = data["new_titletype@OData.Community.Display.V1.FormattedValue"];        
     
                } catch (e) {
                    console.log(error.message);
                }
            }

    For more information you can check below reference -

    https://www.inogic.com/blog/2018/01/dynamics-365-v9-0-xrm-webapi-crud-operations-part-1/

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans