Prerequisetes
you have two data sources and a chart, you want to pass the filter to those and modify on the way..
Basics
the problem starts with conversion from external to internal key, this must be solved by yourself (unfortunatelly)
Working Example
Simple Code as an Idea
// get the filter with external key var externalFilter = DS_1.getFilterExt("0BC_PERS1"); // place an error message for debug APPLICATION.createErrorMessage("Filter External: " + externalFilter); // split the external filter var splittedString = externalFilter.split(";"); // create as many variables as many you need in the array var first = ""; var second = ""; // this array is requried for the "primitive" transformation between internal and external key var anArrayOf5ForLoop = [0,1,2,3,4]; // loop on the splitted external keys splittedString.forEach(function(filterELem, index) { // clean up any spaces filterELem = Convert.replaceAll(filterELem, " ", ""); // very basic conversion from external key to internal key, add 0 (works only for me!) anArrayOf5ForLoop.forEach(function(loopElem, index) { if(filterELem.length < 5) { filterELem = "0" + filterELem; } }); // set the variables based on index if (index == 0) { first = filterELem; } if (index == 1) { second = filterELem; } }); // create an array with all variables, seems empty values are not breaking selection var thirdAsEmpty = ""; var selectionsAsArray = [first, second, thirdAsEmpty]; // just for debug var selectionArrayAsString = ""; selectionsAsArray.forEach(function(selArrayInternalElem, index) { selectionArrayAsString = selectionArrayAsString + " | " + selArrayInternalElem; }); APPLICATION.createErrorMessage("Filter Internal: " + selectionArrayAsString); // hmm, works only for me as I can convert CHART_1.setDataSelection({ "0BC_PERS1": selectionsAsArray }); DS_2.setFilterExt("0BC_PERS1", externalFilter);
Tricky Points
there are some tricky points in the script above.
1) by getFilterExt() you get "external" key, and selection on chart requires "internal" key. you have to conver, this can be done somehow in code - but most probably hard coded...
2) you need to pass an real ARRAY to setDataSelection - and this is a problem, as today you cannot create an array of "dynamic" size, but you can try to create an array of eg. 20 and leave the rest empty, seems this will work.
Source Code
A test source code can be taken from:
DesignStudioBiAppRepository/content.biapp at master · KarolKalisz/DesignStudioBiAppRepository · GitHub
make a try!