To derive a hierarchy from a given structure there is ideally a parent-child relationship of the individual tuples. In such a case, the function BuildHierarchy can be used to create the hierarchy.
If a direct parent-child relationship is only possible via the sequence of tuples and unique parent or child characteristics1), the following approach can be chosen:
We use the following functions and components:
First we store the tupples all in a $$ Variables with name $$Position to run through them in the next step. We then filter out the tuples by parent or child characteristic to form a string containing the hierarchy2). By cleverly applying the selection mode “concatenate” on the rule sets and controlling the separators3) a string can be formed according to the following pattern:
MainPositionID1,MainPositionID2#SubPositionID1#SubPositionID2,MainPositionID3#SubPositionID1
This hierarchy string can finally be split with SplitToArray and the separator “,” into the main positions, which trigger Positions in the target object and then for sub-items are again individually resolved after the separator “#” into the sub-items, which are triggered in the shown example below Positions as CustomItems in the MiddleWare4).
Note: If the same item numbers are expected to come in different positions, then the original position number must be taken into account when creating the hierarchy!
We avoid an intermediate mapping5) which could contain the parent-child relationship.