How can I access the members of a hierarchy.

I want to access all the members of the hierarchy. I used this piece of code but nothing works for me. Is there any other way around?
e.Async = true;
var view = dundas.context.baseViewService.currentView;
var pPT= view.control.getViewParameterByName(‘pPT’)
var ph2 = view.control.adapters.find(nm=> == ‘parameterHierarchy2’)
var hID = ph2.control.hierarchy.entityId
var hierarchyService = new;
var def = hierarchyService.getHierarchyById(hID)
var arr = []
var def = hierarchyService.getMembers(hID,{
“hierarchyUniqueName” : hierarchy.uniqueName,
“levelUniqueName” : hirearchy.levels[hirearchy.levels.length-1].compatibleUniqueName,
arr = members

Hi @anupam.mishra,

Thanks for the code. Can you please elaborate on your specific need, I’m not sure what you mean by ‘access all members of the hierarchy’? Are you simply trying to retrieve the hierarchy values in a metric set?

If I can better understand what you are trying to solve, we can provide a more specific answer.

Hi @Jeff,
Thanks for replying. Actually, I want to access all the members of the hierarchy. For Example, If a hierarchy has n members which are “a,b,c”. then I want to access these “a,b,c” using JS. this hierarchy is basically loaded into a parameter hierarchy filter. By default “All” token is selected. that’s why I need members of the hierarchy. Please suggest.

Hi @anupam.mishra,
I think you should try to instead read the available hierarchies from the metric set that is powering the hierarchy. Here is a sample that I created that reads all of the values from a metric set and outputs them in a data label on the screen like a console.

Just make sure you put a label on the screen called “outputLabel”.

var metricSetId = '6e908f39-9a45-4bf4-9788-0dfaab1def1c';

outputLabel.labelText = "Reading data from Metric Set {" + metricSetId + "} called 'Drill Down to Details (Chart)...'\n\n";

// Request data from a metric set by its ID:
var request = new{ objectId: metricSetId });

// Do not limit the number of rows by paging:
request.pagingOptions.pagingKind =;

// Get the data retrieval service
var dataRetrievalService = dundas.context.getService("DataRetrievalService");

// Make this aysnc
var dataPromise = dataRetrievalService.getData(request);

// Used to show loading animation over the Sankey during the data request
//var viewService = dundas.context.getService("ViewService");

//viewService.showLoadingRestCall(dataPromise, { "element": placeholderElement });

// On data retrieval successful
dataPromise.done(function (results) {
  	outputLabel.labelText += "Columns: \n";
  	for (i=0;i<results[0].cellset.columns.length;i++)
    	outputLabel.labelText += results[0].cellset.columns[i].members[0].caption + "\n";
  	outputLabel.labelText += "\nRows: \n";
  	for (i=0;i<results[0].cellset.rows.length;i++)
    	outputLabel.labelText += results[0].cellset.rows[i].members[0].caption + "\n";

  	outputLabel.labelText += "\nCells: \n";
  	for (i=0;i<results[0].cellset.cells[0].length;i++)
    	outputLabel.labelText += results[0].cellset.cells[0][i].formattedValue + "\n";
1 Like