'Get specific field from property

I am new to JavaScript and Dynamics CRM. I have following code:

var analysisCode = Xrm.Page.getAttribute("rf_analysiscode").getValue()[0].entityValues;

As value for analysisCode, I get following output:

{
    "rf_name":{"name":"rf_name","value":"ABC"},
    "rf_code":{"name":"rf_code","value":"ABC"},
    "createdon":{"name":"createdon","value":"24.1.2022 10.39"}
}

But I want to get just the rf_code. How do I retrieve that?



Solution 1:[1]

Parse your result to JSON like this:

const analysisCodeObj = JSON.parse(analysisCode);

Get rf_code like this:

const rfCodeObj = analysisCodeObj["rf_code"];

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1