Thursday 25 February 2016

CASCADE THE TWO OPTION SET FILEDS

Hi

I came across the scenario:

There is a "Discipline" Optionset , "Specialty" Optionset  and "Sub-Specialty" Two Option Set based on the discipline selected the specialty optionset  will filter and based on the filtered options on the specialty the Sub-Specialty selection  will be filtered.

Here is the javascript code to implement the logic...


function disciplineOptionSet_OnChanged() {
    try {

        var optionsetControl = Xrm.Page.ui.controls.get("new_speciality");
        var options = optionsetControl.getAttribute().getOptions();
        var type = Xrm.Page.getAttribute("new_discipline").getValue();
        if (type == 356110000) {
            optionsetControl.clearOptions();
            for (var i = 0; i < options.length - 1; i++) {
                if (options[i].value == 356110019 || options[i].value == 356110020 || options[i].value == 356110021 || options[i].value == 356110022 || options[i].value == 356110023 || options[i].value == 356110024 || options[i].value == 356110025 || options[i].value == 356110026 || options[i].value == 356110027 || options[i].value == 356110028 || options[i].value == 356110029 || options[i].value == 356110030 || options[i].value == 356110031 || options[i].value == 356110032 || options[i].value == 356110033 || options[i].value == 356110034 || options[i].value == 356110035 || options[i].value == 356110036 || options[i].value == 356110037 || options[i].value == 356110038 || options[i].value == 356110039 || options[i].value == 356110040 || options[i].value == 356110041 || options[i].value == 356110042 || options[i].value == 356110043 || options[i].value == 356110044 || options[i].value == 356110045 || options[i].value == 356110046 || options[i].value == 356110047) {
                    optionsetControl.addOption(options[i], options[i].value);
                }
            }
            //TO DO : Disable/Enable field
        }
        else if (type == 356110001) {
            optionsetControl.clearOptions();
            for (var i = 0; i < options.length - 1; i++) {
                if (options[i].value == 356110003 || options[i].value == 356110034) {
                    optionsetControl.addOption(options[i], options[i].value);
                }

            }
            //TO DO : Disable/Enable field
        }
        else if (type == 356110002) {
            optionsetControl.clearOptions();
            for (var i = 0; i < options.length - 1; i++) {
                if (options[i].value == 356110049) {

                    optionsetControl.addOption(options[i], options[i].value);
                }

            }
        }
        else if (type == 356110003) {
            optionsetControl.clearOptions();
            for (var i = 0; i < options.length - 1; i++) {
                if (options[i].value == 356110050) {
                    optionsetControl.addOption(options[i], options[i].value);
                }

            }
            //TO DO : Disable/Enable field
        }
        else if (type == 356110004) {
            optionsetControl.clearOptions();
            for (var i = 0; i < options.length - 1; i++) {
                if (options[i].value == 356110051 || options[i].value == 356110052) {

                    optionsetControl.addOption(options[i], options[i].value);
                }

            }
            //TO DO : Disable/Enable field
        }
        else if (type == 356110005) {
            optionsetControl.clearOptions();
            for (var i = 0; i < options.length - 1; i++) {
                if (options[i].value == 356110018 || options[i].value == 356110019 || options[i].value == 356110016 || options[i].value == 356110003 || options[i].value == 356110000 || options[i].value == 356110014 || options[i].value == 356110004 || options[i].value == 356110009 || options[i].value == 356110017 || options[i].value == 356110015 || options[i].value == 356110002 || options[i].value == 356110001) {

                    optionsetControl.addOption(options[i], options[i].value);
                }

            }
            //TO DO : Disable/Enable field
        }
        else {

            optionsetControl.clearOptions();
            for (var i = 0; i < options.length - 1; i++) {

                optionsetControl.addOption(options[i]);


            }
            //TO DO : Disable/Enable field
        }
    } catch (e) {
        alert(e);
    }
}
//onLoad event
function Onload_Consultant_Schema() {
    disciplineOptionSet_OnChanged();
    enableDisablesubspecility_OnChange();
}
function onChange_speciality() {
    enableDisablesubspecility_OnChange();
}
enableDisablesubspecility_OnChange = function () {
    //TO DO : Disable all field
    Disable_all_specility_Consultant();
    var type = Xrm.Page.getAttribute("new_speciality").getValue();
    if (type == 356110019) {
        Xrm.Page.getControl("new_anaesthetics").setDisabled(false);
        Xrm.Page.getAttribute("new_anaesthetics").setValue(1);
    } else if (type == 356110020) {
        Xrm.Page.getControl("new_audiologicalmedicine").setDisabled(false);
        Xrm.Page.getAttribute("new_audiologicalmedicine").setValue(1);
    }
    else if (type == 356110021) {
        Xrm.Page.getControl("new_cardiology").setDisabled(false);
        Xrm.Page.getAttribute("new_cardiology").setValue(1);
    }
    else if (type == 356110022) {
        Xrm.Page.getControl("new_clinicalgenetics").setDisabled(false);
        Xrm.Page.getAttribute("new_clinicalgenetics").setValue(1);
    }
    else if (type == 356110023) {
        Xrm.Page.getControl("new_clinicalimmunologyandallergyservice").setDisabled(false);
        Xrm.Page.getAttribute("new_clinicalimmunologyandallergyservice").setValue(1);
    }
    else if (type == 356110024) {
        Xrm.Page.getControl("new_clinicalpharmacology").setDisabled(false);
        Xrm.Page.getAttribute("new_clinicalpharmacology").setValue(1);
    }
    else if (type == 356110025) {
        Xrm.Page.getControl("new_criticalcaremedicine").setDisabled(false);
        Xrm.Page.getAttribute("new_criticalcaremedicine").setValue(1);
    }
    else if (type == 356110026) {
        Xrm.Page.getControl("new_dermatology").setDisabled(false);
        Xrm.Page.getAttribute("new_dermatology").setValue(1);
    }
    else if (type == 356110027) {
        Xrm.Page.getControl("new_endocrinology").setDisabled(false);
        Xrm.Page.getAttribute("new_endocrinology").setValue(1);
    }
    else if (type == 356110028) {
        Xrm.Page.getControl("new_gastroenterology").setDisabled(false);
        Xrm.Page.getAttribute("new_gastroenterology").setValue(1);
    }
    else if (type == 356110004) {
        Xrm.Page.getControl("new_ophthalmology").setDisabled(false);
        Xrm.Page.getAttribute("new_ophthalmology").setValue(1);
    }
    else if (type == 356110009) {
        Xrm.Page.getControl("new_maxillofacialsurgery").setDisabled(false);
        Xrm.Page.getAttribute("new_maxillofacialsurgery").setValue(1);
    }
    else if (type == 356110017) {
        Xrm.Page.getControl("new_paediatricsurgery").setDisabled(false);
        Xrm.Page.getAttribute("new_paediatricsurgery").setValue(1);
    }
    else if (type == 356110015) {
        Xrm.Page.getControl("new_plasticsurgery").setDisabled(false);
        Xrm.Page.getAttribute("new_plasticsurgery").setValue(1);

    }
    else if (type == 356110002) {
        Xrm.Page.getControl("new_traumaorthopaedics").setDisabled(false);
        Xrm.Page.getAttribute("new_traumaorthopaedics").setValue(1);

    }
    else if (type == 356110001) {
        Xrm.Page.getControl("new_urology").setDisabled(false);
        Xrm.Page.getAttribute("new_urology").setValue(1);

    }
    else if (type == 356110000) {
        Xrm.Page.getControl("new_breastsurgery").setDisabled(false);
        Xrm.Page.getControl("new_colorectalsurgery").setDisabled(false);
        Xrm.Page.getControl("new_generalsurgery").setDisabled(false);
        Xrm.Page.getControl("new_transplantationsurgery").setDisabled(false);
        Xrm.Page.getControl("new_uppergastrointestinalsurgery").setDisabled(false);
        Xrm.Page.getControl("new_vascularsurgery").setDisabled(false);
        Xrm.Page.getAttribute("new_breastsurgery").setValue(1);
        Xrm.Page.getAttribute("new_colorectalsurgery").setValue(1);
        Xrm.Page.getAttribute("new_generalsurgery").setValue(1);
        Xrm.Page.getAttribute("new_transplantationsurgery").setValue(1);
        Xrm.Page.getAttribute("new_uppergastrointestinalsurgery").setValue(1);
        Xrm.Page.getAttribute("new_vascularsurgery").setValue(1);

    }
    else if (type == 356110014) {
        Xrm.Page.getControl("new_neurosurgery").setDisabled(false);
        Xrm.Page.getControl("new_spinalsurgeryservice").setDisabled(false);
        Xrm.Page.getAttribute("new_neurosurgery").setValue(1);
        Xrm.Page.getAttribute("new_spinalsurgeryservice").setValue(1);

    }
    else if (type == 356110029) {
        Xrm.Page.getControl("new_clinicalneurophysiology").setDisabled(false);
        Xrm.Page.getControl("new_generalmedicine").setDisabled(false);
        Xrm.Page.getAttribute("new_clinicalneurophysiology").setValue(1);
        Xrm.Page.getAttribute("new_generalmedicine").setValue(1);
    }
    else if (type == 356110030) {
        Xrm.Page.getControl("new_genitourinarymedicine").setDisabled(false);
        Xrm.Page.getAttribute("new_genitourinarymedicine").setValue(1);
    }
    else if (type == 356110031) {
        Xrm.Page.getControl("new_geriatricmedicine").setDisabled(false);
        Xrm.Page.getAttribute("new_geriatricmedicine").setValue(1);
    }
    else if (type == 356110032) {
        Xrm.Page.getControl("new_clinicalhaematology").setDisabled(false);
        Xrm.Page.getAttribute("new_clinicalhaematology").setValue(1);
    }
    else if (type == 356110033) {
        Xrm.Page.getControl("new_infectiousdiseases").setDisabled(false);
        Xrm.Page.getAttribute("new_infectiousdiseases").setValue(1);
    }
    else if (type == 356110034) {
        Xrm.Page.getControl("new_medicaloncology").setDisabled(false);
        Xrm.Page.getAttribute("new_medicaloncology").setValue(1);
    }
    else if (type == 356110035) {
        Xrm.Page.getControl("new_medicalophthalmology").setDisabled(false);
        Xrm.Page.getAttribute("new_medicalophthalmology").setValue(1);
    }
    else if (type == 356110036) {
        Xrm.Page.getControl("new_nephrology").setDisabled(false);
        Xrm.Page.getAttribute("new_nephrology").setValue(1);
    }
    else if (type == 356110037) {
        Xrm.Page.getControl("new_neurology").setDisabled(false);
        Xrm.Page.getAttribute("new_neurology").setValue(1);
    }
    else if (type == 356110038) {
        Xrm.Page.getControl("new_nuclearmedicine").setDisabled(false);
        Xrm.Page.getAttribute("new_nuclearmedicine").setValue(1);
    }
    else if (type == 356110040) {
        Xrm.Page.getControl("new_paediatriccardiology").setDisabled(false);
        Xrm.Page.getAttribute("new_paediatriccardiology").setValue(1);
    }
    else if (type == 356110041) {
        Xrm.Page.getControl("new_paediatricneurology").setDisabled(false);
        Xrm.Page.getAttribute("new_paediatricneurology").setValue(1);
    }
    else if (type == 356110042) {
        Xrm.Page.getControl("new_paediatrics").setDisabled(false);
        Xrm.Page.getAttribute("new_paediatrics").setValue(1);

    } else if (type == 356110043) {
        Xrm.Page.getControl("new_palliativemedicine").setDisabled(false);
        Xrm.Page.getAttribute("new_palliativemedicine").setValue(1);

    }
    else if (type == 356110044) {
        Xrm.Page.getControl("new_rehabilitationservice").setDisabled(false);
        Xrm.Page.getAttribute("new_rehabilitationservice").setValue(1);

    }
    else if (type == 356110045) {
        Xrm.Page.getControl("new_respiratorymedicine").setDisabled(false);
        Xrm.Page.getAttribute("new_respiratorymedicine").setValue(1);

    }
    else if (type == 356110046) {
        Xrm.Page.getControl("new_rheumatology").setDisabled(false);
        Xrm.Page.getAttribute("new_rheumatology").setValue(1);

    }
    else if (type == 356110047) {
        Xrm.Page.getControl("new_sportandexercisemedicine").setDisabled(false);
        Xrm.Page.getAttribute("new_sportandexercisemedicine").setValue(1);

    }
    else if (type == 356110003) {
        Xrm.Page.getControl("new_paediatricearnoseandthroat").setDisabled(false);
        Xrm.Page.getAttribute("new_paediatricearnoseandthroat").setValue(1);

    }
    else if (type == 356110034) {
        Xrm.Page.getControl("new_medicaloncology").setDisabled(false);
        Xrm.Page.getAttribute("new_medicaloncology").setValue(1);

    }
    else if (type == 356110049) {
        Xrm.Page.getControl("new_chemicalpathology").setDisabled(false);
        Xrm.Page.getAttribute("new_chemicalpathology").setValue(1);

    }
    else if (type == 356110050) {
        Xrm.Page.getControl("new_adultmentalillness").setDisabled(false);
        Xrm.Page.getAttribute("new_adultmentalillness").setValue(1);

    }
    else if (type == 356110051) {
        Xrm.Page.getControl("new_clinicaloncology").setDisabled(false);
        Xrm.Page.getAttribute("new_clinicaloncology").setValue(1);

    }//
    else if (type == 356110052) {
        Xrm.Page.getControl("new_diagnosticimaging").setDisabled(false);
        Xrm.Page.getControl("new_interventionalradiology").setDisabled(false);
        Xrm.Page.getAttribute("new_diagnosticimaging").setValue(1);
        Xrm.Page.getAttribute("new_interventionalradiology").setValue(1);

    }
    else if (type == 356110018) {
        Xrm.Page.getControl("new_accidentemergency").setDisabled(false);
        Xrm.Page.getAttribute("new_accidentemergency").setValue(1);

    }
    else if (type == 356110019) {
        Xrm.Page.getControl("new_painmanagement").setDisabled(false);
        Xrm.Page.getAttribute("new_painmanagement").setValue(1);

    }
    else if (type == 356110016) {
        Xrm.Page.getControl("new_cardiacsurgery").setDisabled(false);
        Xrm.Page.getControl("new_cardiothoracicsurgery").setDisabled(false);
        Xrm.Page.getAttribute("new_cardiacsurgery").setValue(1);
        Xrm.Page.getAttribute("new_cardiothoracicsurgery").setValue(1);
    }
    else if (type == 356110003) {
        Xrm.Page.getControl("new_ent").setDisabled(false);
        Xrm.Page.getAttribute("new_ent").setValue(1);

    }
    else if (type == 356110039) {
        Xrm.Page.getControl("new_gynaecologicaloncology").setDisabled(false);
        Xrm.Page.getControl("new_gynaecology").setDisabled(false);
        Xrm.Page.getControl("new_obstetrics").setDisabled(false);
        Xrm.Page.getAttribute("new_gynaecologicaloncology").setValue(1);
        Xrm.Page.getAttribute("new_gynaecology").setValue(1);
        Xrm.Page.getAttribute("new_obstetrics").setValue(1);
    } else {
        Enable_all_specility_Consultant();
    }




}

Disable_all_specility_Consultant = function () {

    Xrm.Page.getControl("new_anaesthetics").setDisabled(true);
    Xrm.Page.getControl("new_audiologicalmedicine").setDisabled(true);
    Xrm.Page.getControl("new_cardiology").setDisabled(true);
    Xrm.Page.getControl("new_clinicalgenetics").setDisabled(true);
    Xrm.Page.getControl("new_clinicalimmunologyandallergyservice").setDisabled(true);
    Xrm.Page.getControl("new_clinicalpharmacology").setDisabled(true);
    Xrm.Page.getControl("new_criticalcaremedicine").setDisabled(true);
    Xrm.Page.getControl("new_dermatology").setDisabled(true);
    Xrm.Page.getControl("new_endocrinology").setDisabled(true);
    Xrm.Page.getControl("new_gastroenterology").setDisabled(true);
    Xrm.Page.getControl("new_ophthalmology").setDisabled(true);
    Xrm.Page.getControl("new_maxillofacialsurgery").setDisabled(true);
    Xrm.Page.getControl("new_paediatricsurgery").setDisabled(true);
    Xrm.Page.getControl("new_plasticsurgery").setDisabled(true);
    Xrm.Page.getControl("new_traumaorthopaedics").setDisabled(true);
    Xrm.Page.getControl("new_urology").setDisabled(true);
    Xrm.Page.getControl("new_breastsurgery").setDisabled(true);
    Xrm.Page.getControl("new_colorectalsurgery").setDisabled(true);
    Xrm.Page.getControl("new_generalsurgery").setDisabled(true);
    Xrm.Page.getControl("new_transplantationsurgery").setDisabled(true);
    Xrm.Page.getControl("new_uppergastrointestinalsurgery").setDisabled(true);
    Xrm.Page.getControl("new_vascularsurgery").setDisabled(true);
    Xrm.Page.getControl("new_neurosurgery").setDisabled(true);
    Xrm.Page.getControl("new_spinalsurgeryservice").setDisabled(true);
    Xrm.Page.getControl("new_clinicalneurophysiology").setDisabled(true);
    Xrm.Page.getControl("new_generalmedicine").setDisabled(true);
    Xrm.Page.getControl("new_genitourinarymedicine").setDisabled(true);
    Xrm.Page.getControl("new_geriatricmedicine").setDisabled(true);
    Xrm.Page.getControl("new_clinicalhaematology").setDisabled(true);
    Xrm.Page.getControl("new_infectiousdiseases").setDisabled(true);
    Xrm.Page.getControl("new_medicaloncology").setDisabled(true);
    Xrm.Page.getControl("new_medicalophthalmology").setDisabled(true);
    Xrm.Page.getControl("new_nephrology").setDisabled(true);
    Xrm.Page.getControl("new_neurology").setDisabled(true);
    Xrm.Page.getControl("new_nuclearmedicine").setDisabled(true);
    Xrm.Page.getControl("new_paediatriccardiology").setDisabled(true);
    Xrm.Page.getControl("new_paediatricneurology").setDisabled(true);
    Xrm.Page.getControl("new_paediatrics").setDisabled(true);
    Xrm.Page.getControl("new_palliativemedicine").setDisabled(true);
    Xrm.Page.getControl("new_rehabilitationservice").setDisabled(true);
    Xrm.Page.getControl("new_respiratorymedicine").setDisabled(true);
    Xrm.Page.getControl("new_rheumatology").setDisabled(true);
    Xrm.Page.getControl("new_sportandexercisemedicine").setDisabled(true);
    Xrm.Page.getControl("new_paediatricearnoseandthroat").setDisabled(true);
    Xrm.Page.getControl("new_medicaloncology").setDisabled(true);
    Xrm.Page.getControl("new_chemicalpathology").setDisabled(true);
    Xrm.Page.getControl("new_adultmentalillness").setDisabled(true);
    Xrm.Page.getControl("new_clinicaloncology").setDisabled(true);
    Xrm.Page.getControl("new_diagnosticimaging").setDisabled(true);
    Xrm.Page.getControl("new_interventionalradiology").setDisabled(true);
    Xrm.Page.getControl("new_accidentemergency").setDisabled(true);
    Xrm.Page.getControl("new_painmanagement").setDisabled(true);
    Xrm.Page.getControl("new_cardiacsurgery").setDisabled(true);
    Xrm.Page.getControl("new_cardiothoracicsurgery").setDisabled(true);
    Xrm.Page.getControl("new_ent").setDisabled(true);
    Xrm.Page.getControl("new_gynaecologicaloncology").setDisabled(true);
    Xrm.Page.getControl("new_gynaecology").setDisabled(true);
    Xrm.Page.getControl("new_obstetrics").setDisabled(true);
    //Given below are the extra field
    Xrm.Page.getControl("new_burnscare").setDisabled(true);
    Xrm.Page.getControl("new_cardiothoracictransplantation").setDisabled(true);
    Xrm.Page.getControl("new_hepatobiliarypancreaticsurgery").setDisabled(true);
    Xrm.Page.getControl("new_oralsurgery").setDisabled(true);
    Xrm.Page.getControl("new_orthodontics").setDisabled(true);
    Xrm.Page.getControl("new_paediatricdentistry").setDisabled(true);
    Xrm.Page.getControl("new_restorativedentistry").setDisabled(true);
    Xrm.Page.getControl("new_spinalsurgeryservice").setDisabled(true);
    Xrm.Page.getControl("new_thoracicsurgery").setDisabled(true);
    Xrm.Page.getControl("new_paediatricmedicaloncology").setDisabled(true);
    //End extra field
    //Set all value to No
    Xrm.Page.getAttribute("new_anaesthetics").setValue(0);
    Xrm.Page.getAttribute("new_audiologicalmedicine").setValue(0);
    Xrm.Page.getAttribute("new_cardiology").setValue(0);
    Xrm.Page.getAttribute("new_clinicalgenetics").setValue(0);
    Xrm.Page.getAttribute("new_clinicalimmunologyandallergyservice").setValue(0);
    Xrm.Page.getAttribute("new_clinicalpharmacology").setValue(0);
    Xrm.Page.getAttribute("new_criticalcaremedicine").setValue(0);
    Xrm.Page.getAttribute("new_dermatology").setValue(0);
    Xrm.Page.getAttribute("new_endocrinology").setValue(0);
    Xrm.Page.getAttribute("new_gastroenterology").setValue(0);
    Xrm.Page.getAttribute("new_ophthalmology").setValue(0);
    Xrm.Page.getAttribute("new_maxillofacialsurgery").setValue(0);
    Xrm.Page.getAttribute("new_paediatricsurgery").setValue(0);
    Xrm.Page.getAttribute("new_plasticsurgery").setValue(0);
    Xrm.Page.getAttribute("new_traumaorthopaedics").setValue(0);
    Xrm.Page.getAttribute("new_urology").setValue(0);
    Xrm.Page.getAttribute("new_breastsurgery").setValue(0);
    Xrm.Page.getAttribute("new_colorectalsurgery").setValue(0);
    Xrm.Page.getAttribute("new_generalsurgery").setValue(0);
    Xrm.Page.getAttribute("new_transplantationsurgery").setValue(0);
    Xrm.Page.getAttribute("new_uppergastrointestinalsurgery").setValue(0);
    Xrm.Page.getAttribute("new_vascularsurgery").setValue(0);
    Xrm.Page.getAttribute("new_neurosurgery").setValue(0);
    Xrm.Page.getAttribute("new_spinalsurgeryservice").setValue(0);
    Xrm.Page.getAttribute("new_clinicalneurophysiology").setValue(0);
    Xrm.Page.getAttribute("new_generalmedicine").setValue(0);
    Xrm.Page.getAttribute("new_genitourinarymedicine").setValue(0);
    Xrm.Page.getAttribute("new_geriatricmedicine").setValue(0);
    Xrm.Page.getAttribute("new_clinicalhaematology").setValue(0);
    Xrm.Page.getAttribute("new_infectiousdiseases").setValue(0);
    Xrm.Page.getAttribute("new_medicaloncology").setValue(0);
    Xrm.Page.getAttribute("new_medicalophthalmology").setValue(0);
    Xrm.Page.getAttribute("new_nephrology").setValue(0);
    Xrm.Page.getAttribute("new_neurology").setValue(0);
    Xrm.Page.getAttribute("new_nuclearmedicine").setValue(0);
    Xrm.Page.getAttribute("new_paediatriccardiology").setValue(0);
    Xrm.Page.getAttribute("new_paediatricneurology").setValue(0);
    Xrm.Page.getAttribute("new_paediatrics").setValue(0);
    Xrm.Page.getAttribute("new_palliativemedicine").setValue(0);
    Xrm.Page.getAttribute("new_rehabilitationservice").setValue(0);
    Xrm.Page.getAttribute("new_respiratorymedicine").setValue(0);
    Xrm.Page.getAttribute("new_rheumatology").setValue(0);
    Xrm.Page.getAttribute("new_sportandexercisemedicine").setValue(0);
    Xrm.Page.getAttribute("new_paediatricearnoseandthroat").setValue(0);
    Xrm.Page.getAttribute("new_medicaloncology").setValue(0);
    Xrm.Page.getAttribute("new_chemicalpathology").setValue(0);
    Xrm.Page.getAttribute("new_adultmentalillness").setValue(0);
    Xrm.Page.getAttribute("new_clinicaloncology").setValue(0);
    Xrm.Page.getAttribute("new_diagnosticimaging").setValue(0);
    Xrm.Page.getAttribute("new_interventionalradiology").setValue(0);
    Xrm.Page.getAttribute("new_accidentemergency").setValue(0);
    Xrm.Page.getAttribute("new_painmanagement").setValue(0);
    Xrm.Page.getAttribute("new_cardiacsurgery").setValue(0);
    Xrm.Page.getAttribute("new_cardiothoracicsurgery").setValue(0);
    Xrm.Page.getAttribute("new_ent").setValue(0);
    Xrm.Page.getAttribute("new_gynaecologicaloncology").setValue(0);
    Xrm.Page.getAttribute("new_gynaecology").setValue(0);
    Xrm.Page.getAttribute("new_obstetrics").setValue(0);
    //Given below are the extra field
    Xrm.Page.getAttribute("new_burnscare").setValue(0);
    Xrm.Page.getAttribute("new_cardiothoracictransplantation").setValue(0);
    Xrm.Page.getAttribute("new_hepatobiliarypancreaticsurgery").setValue(0);
    Xrm.Page.getAttribute("new_oralsurgery").setValue(0);
    Xrm.Page.getAttribute("new_orthodontics").setValue(0);
    Xrm.Page.getAttribute("new_paediatricdentistry").setValue(0);
    Xrm.Page.getAttribute("new_restorativedentistry").setValue(0);
    Xrm.Page.getAttribute("new_spinalsurgeryservice").setValue(0);
    Xrm.Page.getAttribute("new_thoracicsurgery").setValue(0);
    Xrm.Page.getAttribute("new_paediatricmedicaloncology").setValue(0);

}

Enable_all_specility_Consultant = function () {
    Xrm.Page.getControl("new_anaesthetics").setDisabled(false);
    Xrm.Page.getControl("new_audiologicalmedicine").setDisabled(false);
    Xrm.Page.getControl("new_cardiology").setDisabled(false);
    Xrm.Page.getControl("new_clinicalgenetics").setDisabled(false);
    Xrm.Page.getControl("new_clinicalimmunologyandallergyservice").setDisabled(false);
    Xrm.Page.getControl("new_clinicalpharmacology").setDisabled(false);
    Xrm.Page.getControl("new_criticalcaremedicine").setDisabled(false);
    Xrm.Page.getControl("new_dermatology").setDisabled(false);
    Xrm.Page.getControl("new_endocrinology").setDisabled(false);
    Xrm.Page.getControl("new_gastroenterology").setDisabled(false);
    Xrm.Page.getControl("new_ophthalmology").setDisabled(false);
    Xrm.Page.getControl("new_maxillofacialsurgery").setDisabled(false);
    Xrm.Page.getControl("new_paediatricsurgery").setDisabled(false);
    Xrm.Page.getControl("new_plasticsurgery").setDisabled(false);
    Xrm.Page.getControl("new_traumaorthopaedics").setDisabled(false);
    Xrm.Page.getControl("new_urology").setDisabled(false);
    Xrm.Page.getControl("new_breastsurgery").setDisabled(false);
    Xrm.Page.getControl("new_colorectalsurgery").setDisabled(false);
    Xrm.Page.getControl("new_generalsurgery").setDisabled(false);
    Xrm.Page.getControl("new_transplantationsurgery").setDisabled(false);
    Xrm.Page.getControl("new_uppergastrointestinalsurgery").setDisabled(false);
    Xrm.Page.getControl("new_vascularsurgery").setDisabled(false);
    Xrm.Page.getControl("new_neurosurgery").setDisabled(false);
    Xrm.Page.getControl("new_spinalsurgeryservice").setDisabled(false);
    Xrm.Page.getControl("new_clinicalneurophysiology").setDisabled(false);
    Xrm.Page.getControl("new_generalmedicine").setDisabled(false);
    Xrm.Page.getControl("new_genitourinarymedicine").setDisabled(false);
    Xrm.Page.getControl("new_geriatricmedicine").setDisabled(false);
    Xrm.Page.getControl("new_clinicalhaematology").setDisabled(false);
    Xrm.Page.getControl("new_infectiousdiseases").setDisabled(false);
    Xrm.Page.getControl("new_medicaloncology").setDisabled(false);
    Xrm.Page.getControl("new_medicalophthalmology").setDisabled(false);
    Xrm.Page.getControl("new_nephrology").setDisabled(false);
    Xrm.Page.getControl("new_neurology").setDisabled(false);
    Xrm.Page.getControl("new_nuclearmedicine").setDisabled(false);
    Xrm.Page.getControl("new_paediatriccardiology").setDisabled(false);
    Xrm.Page.getControl("new_paediatricneurology").setDisabled(false);
    Xrm.Page.getControl("new_paediatrics").setDisabled(false);
    Xrm.Page.getControl("new_palliativemedicine").setDisabled(false);
    Xrm.Page.getControl("new_rehabilitationservice").setDisabled(false);
    Xrm.Page.getControl("new_respiratorymedicine").setDisabled(false);
    Xrm.Page.getControl("new_rheumatology").setDisabled(false);
    Xrm.Page.getControl("new_sportandexercisemedicine").setDisabled(false);
    Xrm.Page.getControl("new_paediatricearnoseandthroat").setDisabled(false);
    Xrm.Page.getControl("new_medicaloncology").setDisabled(false);
    Xrm.Page.getControl("new_chemicalpathology").setDisabled(false);
    Xrm.Page.getControl("new_adultmentalillness").setDisabled(false);
    Xrm.Page.getControl("new_clinicaloncology").setDisabled(false);
    Xrm.Page.getControl("new_diagnosticimaging").setDisabled(false);
    Xrm.Page.getControl("new_interventionalradiology").setDisabled(false);
    Xrm.Page.getControl("new_accidentemergency").setDisabled(false);
    Xrm.Page.getControl("new_painmanagement").setDisabled(false);
    Xrm.Page.getControl("new_cardiacsurgery").setDisabled(false);
    Xrm.Page.getControl("new_cardiothoracicsurgery").setDisabled(false);
    Xrm.Page.getControl("new_ent").setDisabled(false);
    Xrm.Page.getControl("new_gynaecologicaloncology").setDisabled(false);
    Xrm.Page.getControl("new_gynaecology").setDisabled(false);
    Xrm.Page.getControl("new_obstetrics").setDisabled(false);
    //Given below are the extra field
    Xrm.Page.getControl("new_burnscare").setDisabled(false);
    Xrm.Page.getControl("new_cardiothoracictransplantation").setDisabled(false);
    Xrm.Page.getControl("new_hepatobiliarypancreaticsurgery").setDisabled(false);
    Xrm.Page.getControl("new_oralsurgery").setDisabled(false);
    Xrm.Page.getControl("new_orthodontics").setDisabled(false);
    Xrm.Page.getControl("new_paediatricdentistry").setDisabled(false);
    Xrm.Page.getControl("new_restorativedentistry").setDisabled(false);
    Xrm.Page.getControl("new_spinalsurgeryservice").setDisabled(false);
    Xrm.Page.getControl("new_thoracicsurgery").setDisabled(false);
    Xrm.Page.getControl("new_paediatricmedicaloncology").setDisabled(false);
    //Setting the value 1
    Xrm.Page.getAttribute("new_anaesthetics").setValue(0);
    Xrm.Page.getAttribute("new_audiologicalmedicine").setValue(0);
    Xrm.Page.getAttribute("new_cardiology").setValue(0);
    Xrm.Page.getAttribute("new_clinicalgenetics").setValue(0);
    Xrm.Page.getAttribute("new_clinicalimmunologyandallergyservice").setValue(0);
    Xrm.Page.getAttribute("new_clinicalpharmacology").setValue(0);
    Xrm.Page.getAttribute("new_criticalcaremedicine").setValue(0);
    Xrm.Page.getAttribute("new_dermatology").setValue(0);
    Xrm.Page.getAttribute("new_endocrinology").setValue(0);
    Xrm.Page.getAttribute("new_gastroenterology").setValue(0);
    Xrm.Page.getAttribute("new_ophthalmology").setValue(0);
    Xrm.Page.getAttribute("new_maxillofacialsurgery").setValue(0);
    Xrm.Page.getAttribute("new_paediatricsurgery").setValue(0);
    Xrm.Page.getAttribute("new_plasticsurgery").setValue(0);
    Xrm.Page.getAttribute("new_traumaorthopaedics").setValue(0);
    Xrm.Page.getAttribute("new_urology").setValue(0);
    Xrm.Page.getAttribute("new_breastsurgery").setValue(0);
    Xrm.Page.getAttribute("new_colorectalsurgery").setValue(0);
    Xrm.Page.getAttribute("new_generalsurgery").setValue(0);
    Xrm.Page.getAttribute("new_transplantationsurgery").setValue(0);
    Xrm.Page.getAttribute("new_uppergastrointestinalsurgery").setValue(0);
    Xrm.Page.getAttribute("new_vascularsurgery").setValue(0);
    Xrm.Page.getAttribute("new_neurosurgery").setValue(0);
    Xrm.Page.getAttribute("new_spinalsurgeryservice").setValue(0);
    Xrm.Page.getAttribute("new_clinicalneurophysiology").setValue(0);
    Xrm.Page.getAttribute("new_generalmedicine").setValue(0);
    Xrm.Page.getAttribute("new_genitourinarymedicine").setValue(0);
    Xrm.Page.getAttribute("new_geriatricmedicine").setValue(0);
    Xrm.Page.getAttribute("new_clinicalhaematology").setValue(0);
    Xrm.Page.getAttribute("new_infectiousdiseases").setValue(0);
    Xrm.Page.getAttribute("new_medicaloncology").setValue(0);
    Xrm.Page.getAttribute("new_medicalophthalmology").setValue(0);
    Xrm.Page.getAttribute("new_nephrology").setValue(0);
    Xrm.Page.getAttribute("new_neurology").setValue(0);
    Xrm.Page.getAttribute("new_nuclearmedicine").setValue(0);
    Xrm.Page.getAttribute("new_paediatriccardiology").setValue(0);
    Xrm.Page.getAttribute("new_paediatricneurology").setValue(0);
    Xrm.Page.getAttribute("new_paediatrics").setValue(0);
    Xrm.Page.getAttribute("new_palliativemedicine").setValue(0);
    Xrm.Page.getAttribute("new_rehabilitationservice").setValue(0);
    Xrm.Page.getAttribute("new_respiratorymedicine").setValue(0);
    Xrm.Page.getAttribute("new_rheumatology").setValue(0);
    Xrm.Page.getAttribute("new_sportandexercisemedicine").setValue(0);
    Xrm.Page.getAttribute("new_paediatricearnoseandthroat").setValue(0);
    Xrm.Page.getAttribute("new_medicaloncology").setValue(0);
    Xrm.Page.getAttribute("new_chemicalpathology").setValue(0);
    Xrm.Page.getAttribute("new_adultmentalillness").setValue(0);
    Xrm.Page.getAttribute("new_clinicaloncology").setValue(0);
    Xrm.Page.getAttribute("new_diagnosticimaging").setValue(0);
    Xrm.Page.getAttribute("new_interventionalradiology").setValue(0);
    Xrm.Page.getAttribute("new_accidentemergency").setValue(0);
    Xrm.Page.getAttribute("new_painmanagement").setValue(0);
    Xrm.Page.getAttribute("new_cardiacsurgery").setValue(0);
    Xrm.Page.getAttribute("new_cardiothoracicsurgery").setValue(0);
    Xrm.Page.getAttribute("new_ent").setValue(0);
    Xrm.Page.getAttribute("new_gynaecologicaloncology").setValue(0);
    Xrm.Page.getAttribute("new_gynaecology").setValue(0);
    Xrm.Page.getAttribute("new_obstetrics").setValue(0);
    //Given below are the extra field
    Xrm.Page.getAttribute("new_burnscare").setValue(0);
    Xrm.Page.getAttribute("new_cardiothoracictransplantation").setValue(0);
    Xrm.Page.getAttribute("new_hepatobiliarypancreaticsurgery").setValue(0);
    Xrm.Page.getAttribute("new_oralsurgery").setValue(0);
    Xrm.Page.getAttribute("new_orthodontics").setValue(0);
    Xrm.Page.getAttribute("new_paediatricdentistry").setValue(0);
    Xrm.Page.getAttribute("new_restorativedentistry").setValue(0);
    Xrm.Page.getAttribute("new_spinalsurgeryservice").setValue(0);
    Xrm.Page.getAttribute("new_thoracicsurgery").setValue(0);
    Xrm.Page.getAttribute("new_paediatricmedicaloncology").setValue(0);
}

function OnSave_NameConcatnation() {
    var firstName = Xrm.Page.getAttribute("new_firstname").getValue();
    var lastName = Xrm.Page.getAttribute("new_lastname").getValue();
    Xrm.Page.getAttribute("new_name").setValue(firstName + " " + lastName);
}

function EmailValidation_Primaryemailaddress() {

    var primaryemailaddress = Xrm.Page.getAttribute("new_primaryemailaddress").getValue();
    if (primaryemailaddress != null) {
        var reg = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/
        if (!reg.test(primaryemailaddress)) {
            Xrm.Page.getControl("new_primaryemailaddress").setNotification("please enter valid email address");
            Xrm.Page.getControl("new_primaryemailaddress").setFocus();


        }
    } else {
        Xrm.Page.getControl("new_primaryemailaddress").clearNotification();

    }

}
function EmailValidation_Secondaryemailaddress() {

    var secondaryemailaddress = Xrm.Page.getAttribute("new_secondaryemailaddress").getValue();
    if (secondaryemailaddress != null) {
        var reg = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/
        if (!reg.test(secondaryemailaddress)) {
            Xrm.Page.getControl("new_secondaryemailaddress").setNotification("please enter valid email address");
            Xrm.Page.getControl("new_secondaryemailaddress").setFocus();

        }
    } else {
        Xrm.Page.getControl("new_secondaryemailaddress").clearNotification();
    }

}
function EmailValidation_primarymedicalsecretarypaemailaddress() {

    var primarymedicalsecretarypaemailaddress = Xrm.Page.getAttribute("new_primarymedicalsecretarypaemailaddress").getValue();
    if (primarymedicalsecretarypaemailaddress != null) {
        var reg = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/
        if (!reg.test(primarymedicalsecretarypaemailaddress)) {
            Xrm.Page.getControl("new_primarymedicalsecretarypaemailaddress").setNotification("please enter valid email address");
            Xrm.Page.getControl("new_primarymedicalsecretarypaemailaddress").setFocus();

        }
    } else {
        Xrm.Page.getControl("new_primarymedicalsecretarypaemailaddress").clearNotification();
    }

}

No comments:

Post a Comment

Note: only a member of this blog may post a comment.