Ever encounter problem is cascading drop down?
Cascading in different level ? or maybe just one level.
Using this script.
*Note put this script function cascadingDropdown on the field that onchange to trigger the cascade.
Javascript Eg.
//Function to put in toward field trigger onchange
function cascadingDropdown() {
var Saving = Xrm.Page.data.entity.attributes.get("vw_saving").getValue();
var SavingType = "vw_savingtype";
var picklistTwo = Xrm.Page.getControl(SavingType);
var picklistTwoAttribute = picklistTwo.getAttribute();
if (picklistTwo.flag == true) {
picklistTwo.clearOptions();
var origOptions = picklistTwo.originalPicklistValues;
for (var i = origOptions.length - 1; i >= 0; i--) {
if (origOptions[i].text != "") {
picklistTwo.addOption(origOptions[i]);
}
}
}
else {
picklistTwo.originalPicklistValues = picklistTwoAttribute.getOptions();
picklistTwo.flag = true;
}
var picklistTwoOptions = picklistTwoAttribute.getOptions();
switch (Saving) {
case true:
for (var i = picklistTwoOptions.length - 1; i >= 0; i--) {
if (picklistTwoOptions[i].value != null && picklistTwoOptions[i].value != "") {
var optionText = picklistTwoOptions[i].text;
var optionValue = picklistTwoOptions[i].value;
//Remove these values (This is the problem with hard code)
//U can change the code to get the value too. It depends.
if (optionText == "Negotiation" || optionText == "Discount" || optionText == "Contracting Strategy" || optionText == "Online Bidding (OLB)") {
picklistTwo.removeOption(optionValue);
}
//END: EOS Selection
}
}
break;
case false:
for (var i = picklistTwoOptions.length - 1; i >= 0; i--) {
if (picklistTwoOptions[i].value != null && picklistTwoOptions[i].value != "") {
var optionText = picklistTwoOptions[i].text;
var optionValue = picklistTwoOptions[i].value;
//Remove these values
if (optionText == "Joint Tender" || optionText == "Integrated Tender") {
picklistTwo.removeOption(optionValue);
}
//END: CS Selection
}
}
break;
default:
break;
}
}
End.
The bad thing about this script is if u have thousand or hundred of cascading record, u need to hardcore the value one by one and it takes a lot of time and script line.
For what i suggest if there are thousand or more than thousand of cascading record, better make use of the lookup toward entity. By using lookup it wont be consuming much time in scripting or work with the cascading part.
CRM 2011 Cascading Drop Down
Posted by Unknown at 6/28/2012 05:28:00 pm
Labels: CRM 2011
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment