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)

How to display data from option set into a dropdown.

(0) ShareShare
ReportReport
Posted on by

Hello Everyone.

I am facing an issue in displaying a data in a drop-down based on selection from an 

option set.

I have a Sample as a Custom Entity.

In Sample Entity there is a field name is Cars which have multiple cars in an option set data type.

As I select Cars from options set it should display in a drop-down.

The code is displayed below:-

<html>
<head>
<title> MultiSelection Demo </title>
</head>
<body>
<select multiple id="selectForm">

</select>
</body>
</html>
<script>
var attribute = window.parent.Xrm.Page.getAttribute('smp_optionset');
var optiontable = attribute.getOptions();
var dropdown = document.getElementById("selectForm");
for(var i=0; i<optiontable.length; i++)
{
var text = optiontable[i].text;
var value = optiontable[i].value;

var option = document.createElement("option");
option.text = Text;
option.value = Value;
dropdown.add(option);

alert("Text = " + text + "Value = " + value );

</script>

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at

    what CRM version you working with?

  • Community Member Profile Picture
    on at

    Its an trial version.

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi Ajay Walmiki,

    what type of error you get?

    Have you tried to debug code?

    Please help us to understand better.

    If you found the answer helpful, please mark as Verified 

    Join my network on LinkedIn      Follow me on Twitter 

    Thank You & Best Regards

    Francesco Picchi

    Microsoft Dynamics CRM Consultant, Bologna+Milano, ITALY

    Independent Contractor

    http://www.francescopicchi.com

  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    The code that you have above will just populate the drop down from the web page with the values from the optionset.

    From my understanding of your requirements, what you are looking for in to capture the change event of the optionset and change the value accordingly in the web page (i.e. HTML Web Resource).

    In order to accomplish this, you need to add an OnChange event to your optionset, and in the JavaScript of that event, call a function on the HTML Web Resource, and pass the value of the newly changed optionset item. You can then add code to change the value in your drop down list.

    Hope this helps.

  • Community Member Profile Picture
    on at

    Hi!

    I think you should you write dropdown.appenChild (option); instead of dropdown.add (option) ;,

    Please note that code will substitute all the values at once.

    If your purpose is the current / selected, you should get the current value - window.parent.Xrm.Page.getAttribute ("smp_optionset"). GetValue () ;, and in a loop to get the text of the current value you should substitute it in dropdown. 

    Hope it helps

    Please mark it As Answered or Verified if it did help you.

    Thanks

    Vlad

    http://dynamicalabs.com/

  • Community Member Profile Picture
    on at

    Its not working at all.

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!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans