Blogs / SAP / SAP Analytics Cloud / Application Design / SAP Analytics Cloud – Application Design Series 15 Script Objects

SAP Analytics Cloud – Application Design Series 15 Script Objects

Oct 14, 2019

SHARE

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.


Corporate HQ:
5920 Windhaven Pkwy, Plano, TX 75093

+1 888-227-2794

+1 972-232-2233

+1 888-227-7192

solutions@visualbi.com


Copyright © Visual BI Solutions Inc.

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!

Share This!

Share this with your friends and colleagues!