Wednesday, February 10, 2016

Loop through Optionset and update Value in CRM 2015

function EstimatedLaunchDate() {
    var Estimatelaunchdate = Xrm.Page.data.entity.attributes.get("new_launchdate").getValue();

    alert(Estimatelaunchdate);
    FormatDate(Estimatelaunchdate);

}

function FormatDate(Estimatelaunchdate) {

    if (Estimatelaunchdate != null) {
        var curr_year = Estimatelaunchdate.getFullYear();
        alert(curr_year);

        var pickListField = Xrm.Page.getControl("aces_estimatedtoplinerevenuecurrentyear");
        var options = Xrm.Page.getAttribute("aces_estimatedtoplinerevenuecurrentyear").getOptions();


        for (i = 0; i < options.length; i++) {
            if (options[i].text == curr_year) {
                Xrm.Page.getAttribute("aces_estimatedtoplinerevenuecurrentyear").setValue(options[i].value);
            }


        }

        var picklistval = parseInt(curr_year) + 1;

        var options1 = Xrm.Page.getAttribute("aces_estimatedtoplinerevenuefirstyear").getOptions();


        for (i = 0; i < options.length; i++) {
            if (options[i].text == picklistval) {
                Xrm.Page.getAttribute("aces_estimatedtoplinerevenuefirstyear").setValue(options[i].value);
            }


        }






    }


}

No comments:

Post a Comment