/*
1. Create one seperate Jscript file.
2. Onload_Consultant_Schema() function attached onLoad event on Consultant
3. disciplineOptionSet_OnChanged( ) function attached onChange event on Discipline attribute on consultant
*/
//onChange event
disciplineOptionSet_OnChanged = function () {
var optionsetControl = Xrm.Page.ui.controls.get("new_subspecility");//this is the child or dependent optionSet
var options = optionsetControl.getAttribute( ).getOptions();
var type = Xrm.Page.getAttribute("new_ discipline").getValue();//this is the parent optionSet
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]);
}
}
//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]);
}
}
//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]);
}
}
}
else if (type == 356110003) {
optionsetControl.clearOptions( );
for (var i = 0; i < options.length - 1; i++) {
if (options[i].value == 356110050) {
optionsetControl.addOption( options[i]);
}
}
//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]);
}
}
//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]);
}
}
//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
}
}
//onLoad event
Onload_Consultant_Schema = function () {
disciplineOptionSet_OnChanged( );
}
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.