Decode dependent picklist validFor mapping in Javascript
To process them, you can use the same type of code you see in the documentation. Here's how I'd write this in ES5:
function testBit(bitmap, index) {
// Given an 8-bit binary string, get the index / 8 character,
// And convert the index % 8 bit to true or false
return !!(bitmap.charCodeAt(index >> 3) & (128 >> (index % 8)));
}
function getValidPicklistValues(controlValue, dependentListValues, controllingValues) {
// Figure out the index of the controlValue
var index = controllingValues.indexOf(controllingValues.find(
function(item) { return controlValue === item.value; }
));
// Return a list of matching options given the control value
return dependentListValues.filter(function(item) {
// atob is base64-decoding.
return testBit(atob(item.validFor), index);
});
}
Note that atob is a built-in for web browsers; if you're using a version of JavaScript that doesn't have a Window object, you'll need to base-64 decode the data yourself.