Skip to Content
Technical Articles
Author's profile photo Aleksey Salinin

Analytics Designer Feature Content Q3-Q4 2021

INTRODUCTION

Analytics Designer (AD) Feature Content appeared a long time ago and contains script applications with examples of functionalities and different capabilities. It is very useful and convenient both as a first entry point and as a point help for those who have already started trying to develop AD applications.

This content is in Content network – Sample and is periodically updated

What will be described below applies in particular to content Analytics Designer – Features

after you have deployed / updated this content, it will be available along this path:

NEW FEATURE CONTENT

I propose to consider the Top3 content features that have appeared over the past half a year

  • Sender/Receiver;
  • Collapse Lanes;
  • Script Pattern

1.SENDER / RECEIVER

When: Q3 2021

Description: Learn how to use global variables as url parameter and interpret. Learn how to set variables and/or filters as url parameter and open the receiver application.

App in tenant:

Apps screens:

Structure and main logic:

Sender App

the application has 3 options for passing parameters (can be used simultaneously):

each of them has its own functions:

creating variables to pass to a link:

var selection = CheckboxGroup.getSelectedKeys();
for (var i = 0; i < selection.length; i++) {
	var sel = selection[i];
	if (sel === "1") {
		Utils.getUrlParam_Variables(ds);
		var urlParam_Variables 	= UrlParameter.create("p_Variable",UrlParam_Variables);
	} else if (sel === "2") {
		Utils.getUrlParam_Filters(ds);
		var urlParam_Filter 	= UrlParameter.create("p_Filter",UrlParam_Filters);
	}
	else if (sel === "3") {
		var urlParam_Prompt 	= UrlParameter.create("p_Prompt","true");
	}
}

conditions and application opening:

	if (urlParam_Variables && urlParam_Filter && urlParam_Prompt) {
		NavigationUtils.openApplication(appId,[urlParam_Variables,urlParam_Filter,urlParam_Prompt],true);
	} else if (urlParam_Variables && urlParam_Filter) {
		NavigationUtils.openApplication(appId,[urlParam_Variables,urlParam_Filter],true);
	} else if (urlParam_Variables && urlParam_Prompt) {
		NavigationUtils.openApplication(appId,[urlParam_Variables,urlParam_Prompt],true);
	} else if (urlParam_Variables) {
		NavigationUtils.openApplication(appId,[urlParam_Variables],true);
	} else if (urlParam_Filter) {
		NavigationUtils.openApplication(appId,[urlParam_Filter],true);
	} else if (urlParam_Filter && urlParam_Prompt) {
		NavigationUtils.openApplication(appId,[urlParam_Filter,urlParam_Prompt],true);
	} else if (urlParam_Prompt) {
		NavigationUtils.openApplication(appId,[urlParam_Prompt],true);
	} else {
		NavigationUtils.openApplication(appId,[],true);
	}

Receiver App

the application has 3 script variables with URL parameter option:

main function is checkUrlParameter

//set Variables
if (Variable && Variable !== "") {
	Utils.setVariable();
}
//set Filter
if (Filter && Filter !== "") {
	Utils.setFilter();
}	
//open Prompt
if (Prompt === "true") {
	var ds = Table.getDataSource();
	var variables = ds.getVariables();
	if (variables.length > 0) {
		ds.openPromptDialog();
	} else {
		Application.showMessage(ApplicationMessageType.Info, "No models require prompts");
	}
}

 

2.COLLAPSE LANES

When: Q4 2021

Description: In this example, we will explore how to create collapse lanes.

App in tenant:

 

 

Apps screens:

Structure and main logic:

the main and only function (Lane_setVisible) is a simple switch loop:

switch (Lane) {
	case "1":   
		Lane_1_Content.setVisible(setVisible);
		Lane_1_Expand.setVisible(!setVisible);
		Lane_1_Collapse.setVisible(setVisible);
		break;	
	case "2":   
		Lane_2_Content.setVisible(setVisible);
		Lane_2_Expand.setVisible(!setVisible);
		Lane_2_Collapse.setVisible(setVisible);
		break;		
	case "3":   
		Lane_3_Content.setVisible(setVisible);
		Lane_3_Expand.setVisible(!setVisible);
		Lane_3_Collapse.setVisible(setVisible);
		break;	
		}	

when you click in the header of the lane, 2 arguments of this function are filled:

ScriptObject_Utils.Lane_setVisible("1",!Lane_1_Content.isVisible());

 

3.SCRIPT PATTERN

When: Q4 2021

Description: In this example, we provide different script pattern for copy and paste.

App in tenant:

Apps screens:

Structure and main logic:

there are 10 main buttons in the application and a script object is made for almost each of them

script templates from basic working with dates and format dates:

console.log(["Start - Date"]);

// create a new date with the current date as defautlt
var date_From 	= new Date();
var date_To 	= new Date(); 

console.log(["date_From", date_From, "date_To", date_To]);

// working on date
// set the Year of the date to 2017
var currentYear = date_From.getFullYear();
var neededYear = 2017;
var minus = currentYear - neededYear;
date_From.setFullYear(currentYear - minus );
date_To.setFullYear(currentYear - minus);

// set date format
var dateFrom_string = DateFormat.format(date_From, "yyyy-MM-dd");
var dateTo_string = DateFormat.format(date_To, "yyyy-MM-dd");

console.log(["dateFrom_string", dateFrom_string, "dateTo_string", dateTo_string]);

var range = TimeRange.create(TimeRangeGranularity.Month, date_From,date_To);
Table.getDataSource().setDimensionFilter("Date_703i1904sd",range);

console.log(["End - Date"]);
console.log(["Start - DateFormat"]);

var date 		= new Date();
var dateString 	= DateFormat.format(date, "yyyy-MM-dd");
console.log(["date", date, "dateString", dateString]);

console.log(["End - DateFormat"]);

until demanded resultset:

console.log(["Start - getResultSet"]);

// Returns the result set according to the selected data or context of
// the data you select. Offset/limit should be not less than zero. If
// offset/limit are invalid or not set, all data is returned.
// If the selection does not specify any MeasureDimension, all measures
// are returned.

//Table.getDataSource().getResultSet(selection?: Selection | Selection[] |
//SelectionContext, offset?: integer, limit?: integer): ResultSet[]

// get all result sets
var resultSet = Table.getDataSource().getResultSet();
console.log(["ResultSet", resultSet]);

var convertedResultSet = ResultSet.showResultSet(resultSet);
console.log(["convertedResultSet", convertedResultSet]);

// get all selected result set
var sel = {
    "Product_3e315003an": ["[Product_3e315003an].[ABC].&[PD20]",
						   "[Product_3e315003an].[ABC].&[PD1]"]
};

var selResultSet = Table.getDataSource().getResultSet(sel);
console.log(["selResultSet", selResultSet]);


console.log(["Start - getResultSet"]);

and selections:

console.log(["Start - getSelections"]);

var selections = Table.getSelections();
console.log(["getSelections", selections]);

for (var i = 0; i < selections.length; i++){
	var selection = selections[i];
	for (var dimensionId in selection) {
		var memberId = selection[dimensionId];
		console.log(["dimensionId", dimensionId, "memberId", memberId]);
	}
}

console.log(["End - getSelections"]);

and, as everyone already knows, when run the application, you can see what result these functions return (through the browser console):

SUMMARY

As written earlier in the introduction, this feature content is very useful for those who are going or are already developing AD applications in SAC.

If in the next quarter something else interesting and new will be added, I will definitely update this article.

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.