skipcheck

TM1 client · Docs · Reading and writing data

DrillthroughService

import { DrillthroughService } from "@skipcheck/tm1-client";

Drillthrough: from a cell to the detail behind it, through a drillthrough process (}Drill_…). A cube drillthrough returns a cellset, of a view the process returns; a relational one returns rows from an ODBC source, directly or kept as a Rowset.

A cell's drillthroughs come from the cube's DrillthroughRules, which name the process; scripts lists them for a cell of a cellset. TM1 (11.8) passes such a process the cube's name and the cell's element on each of its dimensions, so the process must declare that many parameters (the cube's name, then one per dimension, in order); otherwise running the cell's drillthrough fails with "process parameter count error" (code 248). Run directly (executeProcess), it takes the parameters given. The returned cellsets and rowsets stay on the server until deleted, like any cellset.

$metadata declares a relational row (DrillthroughRow) with no properties and not open, so its columns would all be lost in a typed row: relational rows come as plain JSON. A rowset's rows (RowsetRow) are open, and keep theirs in dynamicProperties.

Drill from a cell of a query to the detail behind it:

// The detail behind one cell: query it, run its first cube drillthrough, and read the
// cellset that returns. Both cellsets are deleted at the end.
const mdx =
  "SELECT {[Month].[Month].[Jan]} ON 0, {[Region].[Region].[North]} ON 1 FROM [Sales]" +
  " WHERE ([Version].[Version].[Actual], [Measure].[Measure].[Revenue])";
const cells = ODataQuery.none().expand(Cellset.Fields.Cells, (c) => c.select(CellsetCell.Fields.Ordinal, CellsetCell.Fields.Value));
const source = await tm1.cellsets.execute(mdx);
try {
  const scripts = await tm1.drillthrough.scripts(source.ID!, 0).toArray();
  const script = scripts.find((s) => typeOf(Drillthrough, s) === "CubeDrillthrough");
  if (!script) return [];
  const detail = await tm1.drillthrough.execute(source.ID!, 0, script.Name!, cells);
  try {
    return detail.Cells ?? [];
  } finally {
    await tm1.cellsets.delete(detail.ID!);
  }
} finally {
  await tm1.cellsets.delete(source.ID!);
}

Run a drillthrough process directly, with its parameters:

// A drillthrough process run directly, with the parameters it declares
const parameters = [
  ProcessParameterPatch.builder().name("pRegion").value("North").build(),
  ProcessParameterPatch.builder().name("pMonth").value("Jan").build(),
];
const values = ODataQuery.none().expand(Cellset.Fields.Cells, (c) => c.select(CellsetCell.Fields.Value));
const detail = await tm1.drillthrough.executeProcess("}Drill_Sales Detail", parameters, values);
try {
  return detail.Cells ?? [];
} finally {
  await tm1.cellsets.delete(detail.ID!);
}

Read the rows of a relational drillthrough as a rowset:

// Rows from a relational drillthrough, kept as a rowset and streamed from it. Each row's
// columns are properties of the row, by column name.
const rowset = await tm1.drillthrough.executeRelationalProcessWithRowset("}Drill_Sales Orders", []);
try {
  const orders: string[] = [];
  for await (const row of tm1.drillthrough.rows(rowset.ID!)) orders.push(String(row["OrderNumber"]));
  return orders;
} finally {
  await tm1.drillthrough.deleteRowset(rowset.ID!);
}

Members

scriptsThe drillthroughs a cell has, streamed, each a CubeDrillthrough or RelationalDrillthrough (typeOf(Drillthrough, d)).
executetm1.Execute on a cell's cube drillthrough.
executeRelationaltm1.Execute on a cell's relational drillthrough.
executeRelationalWithRowsettm1.ExecuteWithRowset on a cell's relational drillthrough.
executeProcessRuns a cube drillthrough process (such as }Drill_Sales) directly, with its parameters, and returns the cellset of the view it returns, left on the server until deleted.
executeRelationalProcessRuns a relational drillthrough process directly; its rows, as JSON, streamed.
executeRelationalProcessWithRowsetRuns a relational drillthrough process directly, keeping its rows as a rowset.
rowsetGET Rowsets('id').
rowsGET Rowsets('id')/Rows, streamed.
deleteRowsetFrees the rowset on the server.

scripts

scripts(cellset: string, ordinal: number, query?: ODataQuery | null, options?: Tm1CallOptions): Tm1Stream<Drillthrough>

GET Cellsets('id')/Cells(n)/DrillthroughScripts: the drillthroughs a cell has, streamed, each a CubeDrillthrough or RelationalDrillthrough (typeOf(Drillthrough, d)).

TM1 REST Navigation CellsetCell/DrillthroughScripts

execute

execute(cellset: string, ordinal: number, drillthrough: string, query?: ODataQuery | null, options?: Tm1CallOptions): Promise<Cellset>

tm1.Execute on a cell's cube drillthrough: the cellset of the view its process returns, left on the server until deleted. Needs schema 10.2.2.6. The process must take the cube's name and one parameter per dimension (see the class description).

TM1 REST Action CubeDrillthrough/Execute

executeRelational

executeRelational(cellset: string, ordinal: number, drillthrough: string, options?: Tm1CallOptions): Tm1Stream<unknown>

tm1.Execute on a cell's relational drillthrough: its rows, as JSON, streamed. Needs schema 10.2.2.6.

TM1 REST Action RelationalDrillthrough/Execute

executeRelationalWithRowset

executeRelationalWithRowset(cellset: string, ordinal: number, drillthrough: string, options?: Tm1CallOptions): Promise<Rowset>

tm1.ExecuteWithRowset on a cell's relational drillthrough: its rows, kept as a rowset to read with rows. Needs schema 11.6.0.

TM1 REST Action RelationalDrillthrough/ExecuteWithRowset

executeProcess

executeProcess(process: string, parameters: readonly ProcessParameterPatch[], query?: ODataQuery | null, options?: Tm1CallOptions): Promise<Cellset>

ExecuteCubeDrillthrough: runs a cube drillthrough process (such as }Drill_Sales) directly, with its parameters, and returns the cellset of the view it returns, left on the server until deleted. Needs schema 11.2.0.

TM1 REST ActionImport ExecuteCubeDrillthrough

executeRelationalProcess

executeRelationalProcess(process: string, parameters: readonly ProcessParameterPatch[], options?: Tm1CallOptions): Tm1Stream<unknown>

ExecuteRelationalDrillthrough: runs a relational drillthrough process directly; its rows, as JSON, streamed. Needs schema 11.2.0.

TM1 REST ActionImport ExecuteRelationalDrillthrough

executeRelationalProcessWithRowset

executeRelationalProcessWithRowset(process: string, parameters: readonly ProcessParameterPatch[], options?: Tm1CallOptions): Promise<Rowset>

ExecuteRelationalDrillthroughWithRowset: runs a relational drillthrough process directly, keeping its rows as a rowset. Needs schema 11.6.0.

TM1 REST ActionImport ExecuteRelationalDrillthroughWithRowset

rowset

rowset(id: string, query?: ODataQuery | null, options?: Tm1CallOptions): Promise<Rowset>

GET Rowsets('id').

TM1 REST EntitySet Rowsets

rows

rows(id: string, query?: ODataQuery | null, options?: Tm1CallOptions): Tm1Stream<RowsetRow>

GET Rowsets('id')/Rows, streamed: each row's columns are its open properties. Page with $top and $skip.

TM1 REST Navigation Rowset/Rows

deleteRowset

deleteRowset(id: string, options?: Tm1CallOptions): Promise<void>

DELETE Rowsets('id'): frees the rowset on the server.

TM1 REST EntitySet Rowsets