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)

dynamic optionSet

(0) ShareShare
ReportReport
Posted on by

Hello, I need to make one Dynamic OptionSet for states of my country from a Json with JavaScript, but I do not know how can add the new items into my OptionSet.

My JavaScript's code is this:

function CargarEstados(){
    var xhr = new XMLHttpRequest();
    xhr.open('GET', "innovacionesrom3.crm.dynamics.com/.../bln_estados.js", true);
    xhr.send();
    xhr.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
            var response = JSON.parse(xhr.response),
                i = 0;
                for(i; i < response.length; i++) {
                
                console.log(response[i]);
                Xrm.Page.getControl("bln_estadodinamico").addOption(response[i].name, response[i].id);
              
            }
        }
    };
}

The Json is work but does not add the new items.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Gopalan Bhuvanesh Profile Picture
    11,401 on at

    Hi

    You can add/remove the items (options) only when it is already available in the metadata.

    community.dynamics.com/.../415924

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    The easy answer - you can't add whatever you want to optionset and save it to DB. You can only manipulate values if those values are available in metadata of optionset field. Even if somehow you change the list of available values you will get error from CRM Platform during save operation.

    I understand your scenario. I implemented that couple of times and I've done that through html/js webresource.

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)

#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