Changing date hierarchy level in dundas script


I’m trying to change the date hierarchy level (Year/Month/Day) for a chart in a change event script. I’ve read through the “Modify a filter / view parameter using scripting” docs and tried copying examples and not having much luck.

I have a poDate view param, dateChart bar chart, and date range filter control. I added a button to change the level to test this. The script does some other things as well, so have confirmed the rest works fine (showing/hiding series on the chart). The script:

// tested with 0/1/2 for Year/Month/Day
var newLevel = 1;

var viewParameter = this.parentView.control.getViewParameterByName("poDate");

// these are both undefined at first, maybe that's normal?
console.log("Old: " + viewParameter.parameterValue.detailsLevelDepth + ", " + viewParameter.parameterValue.topLevelDepth);

viewParameter.parameterValue.detailsLevelDepth = newLevel;

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

// Sets the value of lastModifiedTime to now

// Update all the connected adapters with the newly modified values
// Includes data visualizations and filter controls

I see the chart refresh, but it never changes the level. I can change level manually by right clicking and “change level” just fine. Using the latest Dundas 8 update for Ubuntu.

Thanks for any insight,


Hi Kevin,

The script looks fine. We do have a working example here -
Do you see any error in the browser development console? It might help in checking why the script does not work. You can also add a debugger and then execute the script in run time one at a time -


1 Like

Thanks for taking a look, Pankaj. I knew it would be some simple mistake and it turns out my view parameter wasn’t setup for HierchyLevel, just AllHierarchyValues. I didn’t realize you needed a separate view param for the level! So I made a poDateLevel param and using that in my script works great.