You need to sign in to do that
Don't have an account?
Jaicen83
getDependentPicklistOptions No Longer Working in Winter 16 Maybe because of Java Changes
Here is the Static Resourcer
Here is the script on the Visualforce page which overrides the standard add products button on the quote line item
All this Code has been working properly for 2 years and when Winter 16 launched it doesn't.
Product group is a dependant picklist off of Product Family which is labeled as Product Line. After the cutover product group in no longer displaing the list of values
/** * getDependentPicklistOptions * * Build an Object in which keys are valid options for the controlling field * and values are lists of valid options for the dependent field. * * Method: dependent PickListEntry.validFor provides a base64 encoded * string. After decoding, each of the bits (reading L to R) * corresponds to the picklist values for the controlling field. */ function getDependentOptions (objName, ctrlFieldName, depFieldName) { // Isolate the Describe info for the relevant fields var objDesc = sforce.connection.describeSObject(objName); var ctrlFieldDesc, depFieldDesc; var found = 0; for (var i=0; i<objDesc.fields.length; i++) { var f = objDesc.fields[i]; if (f.name == ctrlFieldName) { ctrlFieldDesc = f; found++; } else if (f.name == depFieldName) { depFieldDesc = f; found++; } if (found==2) break; } // Set up return object var dependentOptions = {}; var ctrlValues = ctrlFieldDesc.picklistValues; for (var i=0; i<ctrlValues.length; i++) { dependentOptions[ctrlValues[i].label] = []; } var base64 = new sforce.Base64Binary(""); function testBit (validFor, pos) { var byteToCheck = Math.floor(pos/8); var bit = 7 - (pos % 8); return ((Math.pow(2, bit) & validFor.charCodeAt(byteToCheck)) >> bit) == 1; } // For each dependent value, check whether it is valid for each controlling value var depValues = depFieldDesc.picklistValues; for (var i=0; i<depValues.length; i++) { var thisOption = depValues[i]; var validForDec = base64.decode(thisOption.validFor); for (var ctrlValue=0; ctrlValue<ctrlValues.length; ctrlValue++) { if (testBit(validForDec, ctrlValue)) { dependentOptions[ctrlValues[ctrlValue].label].push(thisOption.label); } } } return dependentOptions; } /* var OBJ_NAME = 'Custom_Object__c'; var CTRL_FIELD_NAME = "Controlling_Field__c"; var DEP_FIELD_NAME = "Dependent_Field__c"; var options = getDependentOptions(OBJ_NAME, CTRL_FIELD_NAME, DEP_FIELD_NAME); console.debug(options); */
Here is the script on the Visualforce page which overrides the standard add products button on the quote line item
<script> var j$ = jQuery.noConflict(); j$(document).ready(function() { var OBJ_NAME = 'Product2'; var CTRL_FIELD_NAME = 'Family'; var DEP_FIELD_NAME = 'Product_Group__c'; if ('{!prod.Family}' != '') { var options = getDependentOptions(OBJ_NAME, CTRL_FIELD_NAME, DEP_FIELD_NAME); options['{!prod.Family}'].sort(); j$.each(options['{!prod.Family}'], function (i, item) { j$('.selectProductGroup').append('<option value="'+item+'">'+item+'</option>'); }); j$('.selectProductGroup').change(function() { j$('.selectProductGroupHidden').val(j$('.selectProductGroup').val()); }); $(".selectProductGroup option[value='']").attr("selected", "selected"); j$('.selectProductGroup').val(j$('.selectProductGroupHidden').val()); } }); </script>
All this Code has been working properly for 2 years and when Winter 16 launched it doesn't.
Product group is a dependant picklist off of Product Family which is labeled as Product Line. After the cutover product group in no longer displaing the list of values
Here is the initiation code on the VisualForce Page.