function onChangeFieldSetting(){
var modeValue;
if(Xrm.Page.getAttribute("new_p_modes").getValue() != null)
modeValue = parseInt(Xrm.Page.getAttribute("new_p_modes").getValue());
if(modeValue == 100000000){ //Korea
var korea = Xrm.Page.getAttribute("new_l_korea").controls;
korea.forEach(function(entry){
entry.addPreSearch(function() { addFilter(entry); });
});
} else if(modeValue == 100000001) { //USA
var usa= Xrm.Page.getAttribute("new_l_usa").controls;
usa.forEach(function(entry){
entry.addPreSearch(function() { addFilter(entry); });
});
}
}
function addFilter(fieldcontrol){
if(Xrm.Page.getAttribute("new_l_organization") != null && Xrm.Page.getAttribute("new_l_organization").getValue() != null) {
var organizationName = Xrm.Page.getAttribute("new_l_organization").getValue()[0].name.toString().toUpperCase();
var attributeName = "";
var displayViewName = "";
switch(organizationName){
case "SALES": //Team
attributeName = "new_chk_sales";
displayViewName = "Sales";
break;
case "Support"; //Team (Q&A)
attributeName = "new_";
displayViewName = "Sales";
break;
}
var modeValue;
if(Xrm.Page.getAttribute("new_p_modes").getValue() != null)
modeValue = parseInt(Xrm.Page.getAttribute("new_p_modes").getValue());
var fetchXml = getAccountSearchFilterbyOrg(modeValue,attributeName);
var layoutXml = getAccountSearchFilterbyOrgLayout();
if(modeValue == 100000000){ //Korea
fieldcontrol.addCustomView("{00000000-0000-0000-0000-000000000001}", "account", displayViewName, fetchXml, layoutXml, true);
} else if(modeValue == 100000001) { //USA
fieldcontrol.addCustomView("{00000000-0000-0000-0000-000000000001}", "account", displayViewName, fetchXml, layoutXml, true);
}
}
}
Comments
Post a Comment