This blog post will demonstrate how to pass parameters between two analytics application. Two kind of parameters will be discussed

  • Passing data source filter values across applications
  • Passing constant value  – which can be numeric constant to be leveraged for calculations Or values like SAC Calendar Task Id or user name, values that do not have dimension or variable placeholder in model but still creates necessity to pass the value from one application to other

Consider below application from BestRunJuice sample model. It has below widgets

  • Table
  • Dropdown with all location names
  • Button to navigate to child application
  • Radio button to capture the constant value and pass to child application

 

I – Passing datasource filters to child application

Filtering the table using dropdown selection and passing the same filters to the child application

On Initialization – loading the dropdown with location keys

var location= Table_1.getDataSource().getMembers(“Location_4nm2e04531”);

Dropdown_1.addItem(“Choose Location”,”Choose Location”);

for(var i=0;i<location.length;i++)

{

Dropdown_1.addItem(location[i].id,location[i].description);

}

Dropdown_1.setSelectedKey(“Choose Location”);

On selection of location from dropdown, table’s datasource gets filtered for specific location

Table_1.getDataSource().setDimensionFilter(“Location_4nm2e04531”,Dropdown_1.getSelectedKey())

 

Filter value is to be passed to child application

Step 1:

Create script variable and check the “Expose Variable via URL Parameter” option

 

Step 2:

On click of button “Navigate to Trend Analysis”, call below function by passing child application’s application id

Step 3:

Get the filters applied to the table’s data source. In our use case, we are filtering data in table using location drop down

Step 4:

getFilter() is standard reusable function which fetches the filter values. In our use case it is a single value but this function can be leveraged to handle both single and multiple values, range filters and also exclude option

Single Value Filter:

Multi Value Filter

Step 5:

Once filter value is retrieved from getFilter function, create URL parameter

UrlParam_Filters = filterInfo;

var urlParam_Filter1         = UrlParameter.create(“p_Filter”,UrlParam_Filters);

“Filter” is a global script variable in child application. When indicating the same in the URL parameter, it has to be mentioned as “p_Filter”

On selecting the location from dropdown, table gets filtered as below

Below is how parameters get passed via URL parameter

<<SAC tenant URL>>/app.html#/analyticapp&/aa/CAEA94048C8C010DD59CCE953ABCA400/?p_Filter=Location_4nm2e04531$Single$CT13$false$&url_api=true&mode=present&view_id=appBuilding

  • CAEA94048C8C010DD59CCE953ABCA400 – child app id
  • “Filter” is global script variable in child application
  • “Location_4nm2e04531” is the dimension
  • “Single” is passed as we are passing single value for location
  • Location value  – “CT13” is passed

Child Application

As “Portland” location is passed, we see filter applied in the child application for the same.

Script to be included in the Child Application

Step 1:

Create parameter “Filter” with “Expose variable as URL parameter” option

Step 2: Invoke the setFilter function in the initialization script

Step 3: setFfilter function, to capture the filter values from URL, decode the same and apply in target application

Captured filter value is first applied as filter to Table data source. Same is copied to chart.

II – Passing constant values to child application

Value selected from radio button is passed as constant value to child application. As sample scenario, I am passing true/false values to the child application and accordingly changing visibility of table data source in the child application

Step 1:

Create parameter in parent application “p_Visible” with “Expose variable as URL parameter” option checked

Step 2:

Capture the value of radio button. Check line # 14 to 16 in below script. Create UrlParameter

var urlParam_Filter2 = UrlParameter.create(“p_Visible”,p_Visible);

“Visible” is global script variable in child application but it is to be represented as “p_Visible” in the code.

Step 3:

Check the openApplication syntax where we are passing both URL parameters to the child application. One is datasource filter and other is constant value. As we have more than one URL parameters to pass, it is mentioned within square braces

NavigationUtils.openApplication(appID,[urlParam_Filter1,urlParam_Filter2]);

Step 4:

“Visible” is parameter in child application. Based on the value if passed constant parameter value, widgets visibility is controlled

URL with both parameters that gets generated

<<SAC Tenant URL>>/app.html#/analyticapp&/aa/CAEA94048C8C010DD59CCE953ABCA400/?p_Visible=True&p_Filter=Location_4nm2e04531$Single$CT13$false$&url_api=true&mode=present&view_id=appBuilding

 

Conclusion:

Leveraging this feature, parameters can be passed between analytics applications. This would be useful in multiple use cases

  • Instead of complicating single application, functionalities can be split across multiple applications. Like summary page can be maintained in one application and details can be segregated and maintained as different app. In such cases, filters can be passed from summary to detail
  • In certain scenarios, there might be a need to maintain a landing page where all required filters can be applied. From landing page, users can travel to main application pages. In such scenarios, URLParameter feature can be leveraged to pass values from landing page to other application pages
  • If multiple work files are to be tagged to Calendar Task. Instead of adding multiple work files, main app or landing page can be added as work file. Context values set in task will be applied to landing page. Same can be passed to other work files leveraging this URL Parameter feature. In such scenarios, even the calendar task id can be passed to multiple work files and submission can be done leveraging the Calendar integration feature of analytics application

 

Reference:

Generic SAC Content : https://blogs.sap.com/2021/05/04/sap-analytics-cloud-sample-content-generic-analysis-application-url-parameter/

Sara Sampaio

Sara Sampaio

Author Since: March 10, 2022

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x