hierarchy.removeChild
Removes an element from under one parent in a hierarchy.
What happens to the child depends on where else it sits:
- Under other parents too: it's only removed from the parent you name, and stays under the others.
- A leaf with no other parent: it leaves the hierarchy. If it isn't in any other hierarchy, it becomes an orphan.
- A parent with no other parent: it's left detached, with its children still under it. A detached parent isn't saved, so it and any parents below it are lost when the dimension is next loaded from disk, for example after a server restart, and the leaves below it become orphans.
Removing a parent
This function is meant for leaf elements. To remove a parent from a hierarchy, use hierarchy.unwind, which removes it and everything below it.
The child must be directly under that parent. Elements at the top level of a hierarchy can't be removed this way; use hierarchy.unwind for those. To remove a leaf element from the dimension altogether, including from every hierarchy, use element.delete.
hierarchy.ungroup does exactly the same, but returns an error message instead of false when it fails.
js
hierarchy.removeChild(dimension, hierarchy, parent, child)Parameters
| Parameter | Type | Description |
|---|---|---|
dimension | string | The dimension's name. |
hierarchy | string | The hierarchy's name. |
parent | string | The parent element's name. |
child | string | The child element's name. |
Returns
booleantrue when the child was removed, otherwise false, such as when the dimension, hierarchy, parent or child can't be found, or the child isn't directly under that parent.
Examples
js
hierarchy.removeChild("Account", "Profit and Loss", "Revenue", "Other Sales");