Add child element to parent element while specifying its position using TM1 REST API

In IBM Planning Analytics, there are two functions available to create dimension elements using Turbo Integrator. One way is using DimensionElementInsert and another way is using DimensionElementComponentAdd.

DimensionElementInsert

The syntax for DimensionElementInsert includes an insertion point parameter. This parameter takes an existing element, and the element you’re creating will be placed immediately before that existing element. There’s a pretty annoying drawback: the existing element has to be top level, it can’t be a child of a parent element. Additionally, an element created using this function is never a child element, it’s always a top level element.

DimensionElementComponentAdd

DimensionElementComponentAdd on the other hand can be used to create a child element because this function has a parameter that takes an existing parent element. However, the new child element will be created as the last element under that parent. There’s no opportunity using Turbo Integrator to specify where to place that new child element under the parent element.

tm1.SetComponent

Familiarity with the TM1 REST API comes in handy, specifically tm1.SetComponent. This endpoint allows us to create a child element while specifying its position underneath a parent element.

URL (POST):

/tm1/TM1S_Name/api/v1/Dimensions('Dim_Name')/Hierarchies('Hier_Name')/Elements('Parent_Element_Name')/tm1.SetComponent

Body:

{
  "Element": {
    "Name": "Child_Element_Name"
  },
  "Before@odata.bind":"Dimensions('Dim_Name')/Hierarchies('Hier_Name')/Elements('New_Element_Goes_Before_This_Child_Element')", 
  "Weight":Weight_Goes_Here
}

Acknowledgments:

Thank you to Hubert Heijkers for giving me a hint to explore tm1.SetComponent in the REST API.

Thank you to George Tonkin, specifically his blog post titled Get the most out of Planning Analytics’ logging capabilities. I was a bit stuck getting the right syntax for tm1.SetComponent. His blog inspired me to capture debug-level logging for the REST API, create a child element in PAW, and see what exactly is happening under the covers.

Scroll to Top