Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

In this example i'm giving you a quick overview of how joining arrays and looping through them could be done. This is demonstrated by an onselect Event of a Dropdown component which is dynamically filled in the onstartup Event.

First Go to Tools > Preferences open the Scripting Section on the left side of the screen and click on Templates. Now import the attached template file if it isn't integrated by default.


Now select the onstartup Event of your pagebook and fill in the script code below. Replace "DIMENSION" with the Dimension (technical name) you want to be filled in the Dropdown component. The script joins two arrays of different datasources and checks whether an element is already in the list or not.


var check = 0;
var kpis_ds1 = DS_1.getMembers("DIMENSION", 10);
kpis_ds1.forEach(function(kpi1, index) {
DROPDOWN_2.addItem(kpi1.internalKey, kpi1.text);
});
var kpis_ds2 = DS_2.getMembers("DIMENSION", 10);
kpis_ds2.forEach(function(kpi2, index) {
       kpis_ds1.forEach(function(kpi1, index) {
       if(kpi1==kpi2){
             check=1;
       }
       });
       if(check!=1){
             DROPDOWN_2.addItem(kpi2.internalKey, kpi2.text);
       }
       check=0;
});




After this is done select the Dropdown Box, edit the onselect Event and fill in the following script.


var x = DS_1.getMembers("DIMENSION", 10);             //DS_1 Datasource

x.forEach(function(element, index) {
  if(element.text == DROPDOWN_2.getSelectedValue()){ 
       DS_1.setFilter("DIMENSION", element);
  }
});




That's it. You now have a dynamically filled Dropdown component which is filtering the choosen dimension of your datasource.

Have fun coding!

Labels in this area