function lead_Filter_CustomerType_OnLoad()
{
var customerType = Xrm.Page.getAttribute("inf_customertype").getValue();
if (customerType == 1)
{
Xrm.Page.getControl("inf_leadstatus").removeOption(8); // removeOption use for removing option set value at form load
Xrm.Page.getControl("inf_leadstatus").removeOption(9);
Xrm.Page.getControl("inf_leadstatus").removeOption(10);
Xrm.Page.getControl("inf_leadstatus").removeOption(10);
}
else if(customerType == 2)
{
Xrm.Page.getControl("inf_leadstatus").removeOption(1);
Xrm.Page.getControl("inf_leadstatus").removeOption(2);
Xrm.Page.getControl("inf_leadstatus").removeOption(3);
Xrm.Page.getControl("inf_leadstatus").removeOption(4);
Xrm.Page.getControl("inf_leadstatus").removeOption(5);
Xrm.Page.getControl("inf_leadstatus").removeOption(6);
Xrm.Page.getControl("inf_leadstatus").removeOption(7);
}
}
function lead_Filter_LeadStatusOnLoad()
{
var leadstatus = Xrm.Page.getAttribute("inf_leadstatus").getValue();
if (leadstatus == 8)
{
Xrm.Page.getControl("inf_leadsubstatus").removeOption(4);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(5);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(6);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(7);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(8);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(9);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(10);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(11);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(12);
}
else if (leadstatus == 9)
{
Xrm.Page.getControl("inf_leadsubstatus").removeOption(1);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(2);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(3);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(6);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(7);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(8);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(9);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(10);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(11);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(12);
}
if (leadstatus == 10)
{
Xrm.Page.getControl("inf_leadsubstatus").removeOption(1);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(2);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(3);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(4);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(5);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(11);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(12);
}
if (leadstatus == 11)
{
Xrm.Page.getControl("inf_leadsubstatus").removeOption(1);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(2);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(3);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(4);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(5);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(6);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(7);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(8);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(9);
Xrm.Page.getControl("inf_leadsubstatus").removeOption(10);
}
}
function lead_Filter_CustomerType_OnChange()
{
var customerType = Xrm.Page.getAttribute("inf_customertype").getValue();
var optionSet = Xrm.Page.ui.controls.get("inf_leadstatus");
var optionSetValues = optionSet.getAttribute().getOptions();
optionSet.clearOptions();
if (customerType == 1)
{
optionSetValues.forEach(function (element) {
//using forEach store all option value in eleement
if (element.value == "1")
optionSet.addOption(element);
// addoption use for display option set value at form .
if (element.value == "2")
optionSet.addOption(element);
if (element.value == "3")
optionSet.addOption(element);
if (element.value == "4")
optionSet.addOption(element);
if (element.value == "5")
optionSet.addOption(element);
if (element.value == "6")
optionSet.addOption(element);
if (element.value == "7")
optionSet.addOption(element);
});
}
else if (customerType == 2)
{
optionSetValues.forEach(function (element) {
if (element.value == "8")
optionSet.addOption(element);
if (element.value == "9")
optionSet.addOption(element);
if (element.value == "10")
optionSet.addOption(element);
if (element.value == "11")
optionSet.addOption(element);
});
}
}
function lead_Filter_LeadStatus_onChange()
{
var leadstatus = Xrm.Page.getAttribute("inf_leadstatus").getValue();
var optionSet = Xrm.Page.ui.controls.get("inf_leadsubstatus");
var optionSetValues = optionSet.getAttribute().getOptions();
optionSet.clearOptions();
if (leadstatus == 8)
{
optionSetValues.forEach(function (element) {
if (element.value == "1")
optionSet.addOption(element);
if (element.value == "2")
optionSet.addOption(element);
if (element.value == "3")
optionSet.addOption(element);
});
}
else if (leadstatus == 9)
{
optionSetValues.forEach(function (element) {
if (element.value == "4")
optionSet.addOption(element);
if (element.value == "5")
optionSet.addOption(element);
});
}
else if (leadstatus == 10)
{
optionSetValues.forEach(function (element) {
if (element.value == "6")
optionSet.addOption(element);
if (element.value == "7")
optionSet.addOption(element);
if (element.value == "8")
optionSet.addOption(element);
if (element.value == "9")
optionSet.addOption(element);
if (element.value == "10")
optionSet.addOption(element);
});
}
else if (leadstatus == 11)
{
optionSetValues.forEach(function (element) {
if (element.value == "8")
optionSet.addOption(element);
if (element.value == "11")
optionSet.addOption(element);
if (element.value == "12")
optionSet.addOption(element);
});
}
}