ElementService
import { ElementService } from "@skipcheck/tm1-client"; Elements: /Dimensions('d')/Hierarchies('h')/Elements, an element's parents,
components and edges, and the operations bound to an element.
TM1 (11.8) ignores Name in an element PATCH, so elements can't be renamed, and
rejects Attributes, whose values are cells of the
}ElementAttributes_<dimension> cube. update refuses
both, saying why.
List elements with a query: here, the consolidations.
// The names of the consolidated elements, in name order
const consolidated = ODataQuery.none()
.select(Element.Fields.Name)
.filter(Element.Fields.Type.eq(ElementType.literal(ElementType.Consolidated)))
.orderBy(Element.Fields.Name);
const elements = await tm1.elements.list("Region", "Region", consolidated).toArray();
return elements.map((element) => element.Name!);
Add an element under a consolidation. A new element is a root until it has a parent:
// A new element is a root; SetComponent then puts it last under Total
await tm1.elements.create("Region", "Region", ElementPatch.builder().name("West").type(ElementType.Numeric).build());
await tm1.elements.setComponent("Region", "Region", "Total", "West");
Read a consolidation's children:
// The children of Total, in order
const components = await tm1.elements.components("Region", "Region", "Total", ODataQuery.none().select(Element.Fields.Name)).toArray();
return components.map((element) => element.Name!);
Members
list | The hierarchy's elements, streamed. |
get | The element, or a Tm1NotFoundException if there's none. |
create | Adds an element, as a root of the hierarchy. |
update | Changes the properties the patch sets, such as its type. |
delete | DELETE …/Elements('e'), with the element's edges and data. |
parents | The consolidations the element is in, streamed. |
components | The element's children, in order, streamed. |
edges | The edges to the element's children, streamed. |
hierarchy | The element's hierarchy. |
setComponent | Makes child a child of parent, with weight 1, placed *last* among its children. |
setComponent | Makes child a child of parent with a weight, placed last among its children. |
setComponent | Makes child a child of parent with a weight, placed just before the child before. |
setComponent | |
lock | Stops everyone else changing the element until it's unlocked. |
unlock | tm1.Unlock. |
reserve | Stops everyone else changing the element's data until it's released. |
release | tm1.Release. |
list
list(dimension: string, hierarchy: string, query?: ODataQuery | null, options?: Tm1CallOptions): Tm1Stream<Element>GET …/Hierarchies('h')/Elements: the hierarchy's elements, streamed.
TM1 REST Navigation Hierarchy/Elements
get
get(dimension: string, hierarchy: string, element: string, query?: ODataQuery | null, options?: Tm1CallOptions): Promise<Element>GET …/Elements('e'): the element, or a Tm1NotFoundException if there's none.
TM1 REST Navigation Hierarchy/Elements
create
create(dimension: string, hierarchy: string, element: ElementPatch, options?: Tm1CallOptions): Promise<Element>POST …/Elements: adds an element, as a root of the hierarchy. It needs a name, and a type unless it's numeric; returns the element as created.
TM1 REST Navigation Hierarchy/Elements
update
update(dimension: string, hierarchy: string, element: string, patch: ElementPatch, etag?: string | null, options?: Tm1CallOptions): Promise<void>PATCH …/Elements('e'): changes the properties the patch sets, such as its type. With etag (element["@odata.etag"], from a read), sent as If-Match: only if the element hasn't changed since, else a Tm1PreconditionFailedException.
Throws a RangeError at once if the patch sets Name, which TM1 ignores, or Attributes, which it rejects.
TM1 REST Navigation Hierarchy/Elements
delete
delete(dimension: string, hierarchy: string, element: string, options?: Tm1CallOptions): Promise<void>DELETE …/Elements('e'), with the element's edges and data.
TM1 REST Navigation Hierarchy/Elements
parents
parents(dimension: string, hierarchy: string, element: string, query?: ODataQuery | null, options?: Tm1CallOptions): Tm1Stream<Element>GET …/Elements('e')/Parents: the consolidations the element is in, streamed.
TM1 REST Navigation Element/Parents
components
components(dimension: string, hierarchy: string, element: string, query?: ODataQuery | null, options?: Tm1CallOptions): Tm1Stream<Element>GET …/Elements('e')/Components: the element's children, in order, streamed.
TM1 REST Navigation Element/Components
edges
edges(dimension: string, hierarchy: string, element: string, query?: ODataQuery | null, options?: Tm1CallOptions): Tm1Stream<Edge>GET …/Elements('e')/Edges: the edges to the element's children, streamed.
TM1 REST Navigation Element/Edges
hierarchy
hierarchy(dimension: string, hierarchy: string, element: string, query?: ODataQuery | null, options?: Tm1CallOptions): Promise<Hierarchy>GET …/Elements('e')/Hierarchy: the element's hierarchy.
TM1 REST Navigation Element/Hierarchy
setComponent
setComponent(dimension: string, hierarchy: string, parent: string, child: string, options?: Tm1CallOptions): Promise<void>tm1.SetComponent: makes child a child of parent, with weight 1, placed *last* among its children. ($metadata doesn't say; TM1 11.8 puts it last.)
TM1 REST Action Element/SetComponent
setComponent
setComponent(dimension: string, hierarchy: string, parent: string, child: string, weight: number, options?: Tm1CallOptions): Promise<void>tm1.SetComponent: makes child a child of parent with a weight, placed last among its children.
TM1 REST Action Element/SetComponent
setComponent
setComponent(dimension: string, hierarchy: string, parent: string, child: string, before: string, weight: number, options?: Tm1CallOptions): Promise<void>tm1.SetComponent: makes child a child of parent with a weight, placed just before the child before.
TM1 REST Action Element/SetComponent
setComponent
setComponent( dimension: string, hierarchy: string, parent: string, child: string, before?: string | number | Tm1CallOptions, weight?: number | Tm1CallOptions, options?: Tm1CallOptions, ): Promise<void>TM1 REST Action Element/SetComponent
lock
lock(dimension: string, hierarchy: string, element: string, options?: Tm1CallOptions): Promise<void>tm1.Lock: stops everyone else changing the element until it's unlocked. Needs schema 11.8.23.
TM1 REST Action Element/Lock
unlock
unlock(dimension: string, hierarchy: string, element: string, options?: Tm1CallOptions): Promise<void>tm1.Unlock. Needs schema 11.8.23.
TM1 REST Action Element/Unlock
reserve
reserve(dimension: string, hierarchy: string, element: string, options?: Tm1CallOptions): Promise<void>tm1.Reserve: stops everyone else changing the element's data until it's released. Needs schema 11.8.34.
TM1 REST Action Element/Reserve
release
release(dimension: string, hierarchy: string, element: string, options?: Tm1CallOptions): Promise<void>tm1.Release. Needs schema 11.8.34.
TM1 REST Action Element/Release