Quantcast
Channel: Visual BI Solutions
Viewing all articles
Browse latest Browse all 989

SAP Analytics Cloud – Application Design Series 15 – Script Objects

$
0
0

In the previous blog in this series, we learned how to pass parameters to Web Intelligence. In this blog, let us look at Script Objects and learn to implement them in an analytic application.

Script objects can be a group of script functions that are used to implement a certain functionality or logic. They can be reused within the application. You can also pass parameters to a script function and get results accordingly.

Let us consider a scenario where you have four charts – Top 10 Super Commodities, Sectors, Entities and Spend Trend. On making selection on any of the first three charts, the selection should be filtered on the Spend Trend chart. Let us learn how script objects can be useful to achieve the functionality shown below.

sap-analytics-cloud-application-design-series-15-script-objects

 

Adding a Script Object and Script Function

1. A new script object can be added from the left panel using the plus icon.

sap-analytics-cloud-application-design-series-15-script-objects

 

2. By default, a script function ‘function1’ is created.

sap-analytics-cloud-application-design-series-15-script-objects

 

3. A pop up opens where you can configure the function.

4. Let us enter the name as ‘Func_Filter’. You can also appropriate description.

5. This function does not need to return any value. So, select Return Type as void.

 

Script Function Arguments

1. The script function should take two input arguments.

2. Add one argument of type Chart.

sap-analytics-cloud-application-design-series-15-script-objects

 

3. And another one of a type String array.

sap-analytics-cloud-application-design-series-15-script-objects

 

4. Once the arguments are added click Done.

sap-analytics-cloud-application-design-series-15-script-objects

 

Adding Script

Click on the function icon on the left side panel to open the Script Editor.

sap-analytics-cloud-application-design-series-15-script-objects

 

You can use the script function to copy filters from one chart to another where the name of the chart and dimension is passed as arguments. With the use of APIs copyDimensionFilter() you can replicate the filter conditions. Here the trend chart is filtered according to the filter values available in the main chart.

sap-analytics-cloud-application-design-series-15-script-objects

 

Calling Script Function

Once the script has been set for the script function, it can be executed /called from any widget. Here the script function needs to be called whenever the results of the chart widgets on the top have changed.

In the onResultChanged event of all the three chart components call the script function by passing two parameters – chart name and dimension name array. Func_Filter has two input arguments – GV_Chart and GV_Dimension – of type Chart and String array.

sap-analytics-cloud-application-design-series-15-script-objects

 

Add the script to other charts as well.

sap-analytics-cloud-application-design-series-15-script-objects

 

sap-analytics-cloud-application-design-series-15-script-objects

Now you can run the application and test the scenario.

 

Reach out to us here today if you are interested in evaluating if SAP Analytics Cloud is right for you.

Subscribe to our Newsletter

The post SAP Analytics Cloud – Application Design Series 15 – Script Objects appeared first on Visual BI Solutions.


Viewing all articles
Browse latest Browse all 989

Trending Articles