---
url: /process-functions/hierarchy-rootelements.md
description: Returns the top-level elements of a hierarchy.
---

# hierarchy.rootElements

Returns the top-level elements of a hierarchy.

```js
hierarchy.rootElements(dimension, hierarchy)
```

## Parameters

| Parameter | Type | Description |
|---|---|---|
| `dimension` | `string` | The dimension's name or id. |
| `hierarchy` | `string` | The hierarchy's name or id. |

## Returns

The names of the top-level elements as a JSON string. Read it with `JSON.parse()`. Returns a message starting with `"Error:"` when the dimension or hierarchy can't be found.

## Examples

```js
const members = JSON.parse(hierarchy.rootElements("Account", "Profit and Loss"));
```
