Set different hierarchy level for a tenant

Hi,


I am trying to assign a hierarchy level filter based on a tenant id in a loading script, so that as soon as some one from that tenant enters they are drilled down to the respected hierarchy level. But, I am still not sure where this is going wrong. Can someone help me figure this out ?


// get current tenantId
var tenID = window.dundas.context.currentSession.tenantId;

if(tenID == '56004983-c099-47eb-b821-0378cddbd769') {
// set the hierarchy level parameter, see below

// Get the parent view.
var parentView = this.parentView;

// Get the view parameters.
var viewParameter =
parentView.control.viewParameters;

// Using the library, get the view parameter based on it's name
var viewParameter =
this.parentView.control.getViewParameterByName("viewParameter1");

//viewParameter.parameterValue.clearTokens();

//viewParameter.parameterValue.clearValues();

if(hierarchyLevelList.value == "executive_area")
{
// Set the details level to the product category level, the top level.
viewParameter.parameterValue.detailsLevelDepth = 0;
}
else if(hierarchyLevelList.value == "area")
{
// Set the details level to the product sub category level, the second level.
viewParameter.parameterValue.detailsLevelDepth = 1;
}
else if(hierarchyLevelList.value == "region")
{
// Set the details level to the product level, the thrid level.
viewParameter.parameterValue.detailsLevelDepth = 2;
}
else if(hierarchyLevelList.value == "location_name")
{
// Set the details level to the product level, the fourth level.
viewParameter.parameterValue.detailsLevelDepth = 3;
}

// Set the top level depth to show details level depth.
viewParameter.parameterValue.topLevelDepth = 2;

// Sets the value of lastModifiedTime to now
viewParameter.invalidateLastModifiedTime();

// Update all the connected adapters with the newly modified values
// Includes data visualizations and filter controls
viewParameter.refreshAllAdapters();

}



Hello Sunil,


What seems to be the issue is how you are accessing your view parameter. To access it, make sure you have a view parameter created and connected to the level you want to modify.


  • For your script, you will have to retrieve the view parameter from your dashboard (currently your script is storing a list of view parameters into the viewParameter variable when what you want to do is retrieve the specific view parameter you’re interested in). Below is an example of how you could retrieve a view parameter who’s script name is “viewParameter1”:

var myParameter1 = baseViewService.currentView.control.viewParameters.filter(function(item) {

return item.name === "viewParameter1";

})[0];


Here is an article on view parameter using scripting – Section 5.2 for reference.


Let me know if it worked.


Regards,


Larsen Friis