Pass URL-Filter on BW Live Hierarchy Nodes from Story to Story

Introduction:

Currently it is not possible to pass an URL-Filter on Hierarchy Nodes for BW-Live Models with the standard options.

In this blog I´ll show how this can be accomplished with some simple scripting and story setup.

Use Case:

There is one story which contains input controls (or story filters) for specific dimensions with hierarchies and we would like to pass the selected members of the hierarchy (be it nodes or leafs) to another story where these values should be applied as respective filters again.

Solution:

The jump to the other story is bound to a specific action, e.g. click on a button. This Event will be used to derive the selected members and pass them as URL parameters.

The event contains the following script (example for two relevant dimensions on input controls):

var dim1_string = "";
//only retrieve selected members if not all selected
if(IC_Dim1.getInputControlDataSource().isAllMembersSelected() === false){
	var mem1 = IC_Dim1.getInputControlDataSource().getActiveSelectedMembers(10000);
	for(var i=0;i<mem1.length;i++){
		if(mem1[i].id.startsWith("PSEUDO")){ //really selected members
			if(mem1[i].id.endsWith("-")){ //is a node
				dim1_string = dim1_string.concat("/0HIER_NODE!".concat(mem1[i].displayId));
			}
			else{ //is a leaf
				dim1_string = dim1_string.concat("/!".concat(mem1[i].displayId));
			}
		}
	}
}
	var p_dim1 = UrlParameter.create("p_dim1", dim1_string);

var dim2_string = "";
//only retrieve selected members if not all selected
if(IC_Dim2.getInputControlDataSource().isAllMembersSelected() === false){
	var mem2 = IC_Dim2.getInputControlDataSource().getActiveSelectedMembers(100000);
	for(var j=0;j<mem2.length;j++){
		if(mem2[j].id.startsWith("PSEUDO")){ //really selected members
			if(mem2[j].id.endsWith("-")){ //is a node
				dim2_string = dim2_string.concat("/0HIER_NODE!".concat(mem2[j].displayId));
			}
			else{ //is a leaf
				dim2_string = dim2_string.concat("/!".concat(mem2[j].displayId));
			}
		}
	}
}
	var p_dim2 = UrlParameter.create("p_dim2", dim2_string);

	NavigationUtils.openStory("STORY_ID", "PAGE_ID", [p_dim1, p_dim2]);

Important to note is:

  • Also the implicitly selected members (aka leafs below a node) will be retieved from the “getActiveSelectedMembers” API. Hence, the allowed members need to be increased for most hierarchies (because the default is 100) – if multiple extremely big hierarchies are involved the performance and response time should be checked.
  • The “really” selected members are starting in “id” with “PSEUDO” and nodes are ending with “-“

  • This concept is used to find the relevant IDs and decide which enhancement needs to be made to fit the expected BW syntax – either “0HIER_NODE!” or just “!”
  • All members are concatenated into a string and seperated by “/” (other characters also possible, should not interfer with the expected member IDs)
  • These strings are handed over to an URL parameter and used in the NavigationUtils.openStory API

If the same should be done for story filters, the API “Application.getFileDataSource.getDimensionFilters” can be used which immediately only gives back the chosen nodes/leafs with the correct BW syntax. They can directly be concatenated into a string.

In the story on the receiving end these parameters are maintained as script variables:

E.g. in the onInit script, the parameters can be split into the members and applied to an input control (example of first dimension):

if(dim1.length>0){
var dim1_param = dim1.slice(1); //remove first char, is "/"
var dim1_arr = dim1_param.split("/");
IC_Dim1.getInputControlDataSource().setSelectedMembers(dim1_arr);
}

With this the correct hierarchy filters from Story 1 are passed to Story 2.

Rating: 0 / 5 (0 votes)