Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 82002

After Setting Optionset the get options() is not returning the Optionset

$
0
0

Hi,

On my formLoad

I am assigning new Optionsets base on pre Optionset setting.  I am clearing the original and adding new Optionsets

My below code seems to be working correctly.

function setSampleCodes() {
    var iselect = "?$top=5&$select=new_sampleId,new_name";  // Retreive over 250 records
    //var ifilter = "&$filter=(new_ChildQuestions/Id eq guid'" + questionid.replace(/{/g, "").replace(/}/g, "") + "')";
    var iorderby = "&$orderby=new_name";
    var options = iselect + iorderby;

    var res = SDK.REST.retrieveMultipleRecords("new_sample", options, sampleCodeCallBack, errorHandler, retrieveComplete);
}


function sampleCodeCallBack(retrievedData) {

    var sampleCodeControl = Xrm.Page.getControl("new_samplecode");
    var sampleCodeOptionSets = sampleCodeControl.getOptions();

    //Clear the option set on the control
    if (sampleCodeControl != null && sampleCodeControl != undefined)
        sampleCodeControl.clearOptions();
 
    //Loop and build a new option set for the control
    for (var sc = 0; sc < sampleCodeOptionSets.length; sc++) {
        var sampleOption = sampleCodeOptionSets[sc];
        if (retrievedData.length > 0) {
            for (var rd = 0; rd < retrievedData.length; rd++) {

                const sample = retrievedData[rd];

                var addopionsetValue = 100000000 + rd; // get all optionset value which will be added

                // add  all option  from the object retrievedData
                // Link a description to the option set
                if (sampleOption.value == addopionsetValue) {
                    sampleOption.text = sample.new_name;
                    sampleCodeControl.addOption(sampleOption);
                    Xrm.Page.getControl("new_samplecode").addOption(sampleOption);
                }
            }
        }
    }
}

My problem is when using

Xrm.Page.getAttribute("new_samplecode").getOptions()

I am not getting the 4 Optionsets  I am getting the original Optionsets from the first image.

What am I doing wrong?


Viewing all articles
Browse latest Browse all 82002

Latest Images

Trending Articles



Latest Images