Skip to main content

Posts

Showing posts from October, 2020

Get/Set the Dynamics 365 Option Set text and values.

There are many scenarios where we need to get the option name and value of the option-set field. The below code can be used to retrieve the option name and its values. 1. To get option name from OptionSet Below code can be used to get the option name by passing the option value. function getOptionDetails() { var optionDetails = Xrm.Page.getAttribute("SchemaNameofOptionsetField").getOption(OptionsetValue); if (optionDetails != null) { //To get text of the option set. var optionText = optionDetails.text; alert("OptionSet Text:" + optionText); } } 2. To get the text and value of the selected CRM OptionSet Below code can be used to get the text and value of selected optionset: function getSelectedOptionset() { var selectedOptionset = Xrm.Page.getAttribute("SchemaNameofOptionsetField").getSelectedOption(); if (selectedOptionset != nul