1.
IF ELSE
if (condition) {
// this block will be executed if condition is true
} else {
// this block will be executed if condition is false
2. SWITCH
var selectedCountry = [Link]();
switch (selectedCountry) {
case "Germany":
// code that is relevant for Germany
break;
case "USA":
// code that is relevant for USA
break;
default:
// code that is relevant for all other countries
3. FOR--: to log all hierarchies from data source to console with FOR
var Hierarchies = TBL_Quantity.getDataSource().getHierarchies("0D_NW_PRID");
for (var j=0; j<[Link]; j++){
[Link](Hierarchies[j].id +" - " + Hierarchies[j].description);
}
4. WHILE--: to log all hierarchies from data source to console with WHILE
var Hierarchies = TBL_Quantity.getDataSource().getHierarchies("0D_NW_PRID");
var x = 0;
while (x < [Link]) {
[Link](Hierarchies[x].id +" - " + Hierarchies[x].description);
x++;
5. SHOW OR HIDE A WIDGET ON CLICK A KPI TILE
TILE 1 :
if (TS_Content.isVisible() === false) {
TS_Content.setVisible(true);
TS_Content.setSelectedKey("Tab_1");
TILE2 :
if (TS_Content.isVisible() === false) {
TS_Content.setVisible(true);
TS_Content.setSelectedKey("Tab_2");
6. ARRAY
Arrays are identified by [ ] as shown in the previous example above and can be:
- Printed to console
var resultset = Table_1.getDataSource().getResultSet();
[Link](resultset);
- Accessed with loop
var resultset = Table_1.getDataSource().getResultSet();
for (var x=0; x<[Link]; x++){
[Link](resultset[x]["@MeasureDimension"].rawValue);
- Accessed with index
var resultset = Table_1.getDataSource().getResultSet();
[Link](resultset[1]);
- Scripting Situation Variable
Create empty array var myList = [Link]([Link]);
Create filled array var myList = ["Hello", "World", "Example"]
Add element [Link]("Hello world");
Remove last element [Link]();
Read number of entries [Link];
7. dynamically populate the dropdown:
var countries = Table_1.getDataSource().getMembers("0D_NW_BP__0D_NW_CNTRY");
for (var x = 0; x < [Link]; x++ ) {
var country = countries[x];
Dropdown_1.addItem([Link], [Link]);
8. return an array of all charts in your story with a name starting with "CH_Tile"
var tilecharts = [Link]({type:[Link], searchPattern:"CH_Tile"});
[Link] (tilecharts);
9. to enhance an existing story with a dropdown to filter the Order Quantity table by
product category
var ProductABCratingList =
TBL_Quantity.getDataSource().getMembers("0D_NW_PRID__0D_NW_PRCAT");
for (var i=0; i<[Link]; i++){
if (ProductABCratingList[i].id !== ""){
DD_Product_ABC_rating.addItem(ProductABCratingList[i].displayId,
ProductABCratingList[i].description);
10. to the dropdown using the onSelect action:
TBL_Quantity.getDataSource().setDimensionFilter("0D_NW_PRID__0D_NW_PRCAT",
DD_Product_ABC_rating.getSelectedKey());
STEP 9 AND 10 IS FOR DYNAMIC DROPDOWN