Applying Alternative Hierarchy in Selection

Below is the example of using the ChangeDimSelection operation to apply an alternative hierarchy in the selection of the dictionary elements. The request contains moniker of opened dictionary instance and the alternative hierarchy identifier and also the parameters for changing the selection, according to which the selection is made after applying the alternative hierarchy. The response contains the summary information on the selected elements and the moniker of the new instance of the dictionary.

SOAP request:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ChangeDimSelection xmlns="http://www.fsight.ru/PP.SOM.Som">
<tDim xmlns="">
  <id>S1!M!S!S1</id>
  </tDim>
<tArg xmlns="">
  <newInstance>true</newInstance>
<setHierarchy>
  <id>SOURCE1</id>
  </setHierarchy>
  <elSelectOp>Unknown</elSelectOp>
  <elRelative>Unknown</elRelative>
<next>
  <elSelectOp>Select</elSelectOp>
  <elRelative>All</elRelative>
  </next>
  </tArg>
  </ChangeDimSelection>
  </s:Body>
  </s:Envelope>

SOAP response:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ChangeDimSelectionResult xmlns="http://www.fsight.ru/PP.SOM.Som" xmlns:q1="http://www.fsight.ru/PP.SOM.Som" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <id xmlns="">S1!M!S!S6</id>
<selectionInfo xmlns="">
<firstSelected>
  <n>One elemen</n>
<a>
  <it>One elemen</it>
  <it>1</it>
  <it>1</it>
  <it>0</it>
  <it>A000123</it>
  </a>
<ea>
  <it v="One elemen" />
  <it v="1" />
  <it v="1" />
  <it v="0" />
  <it v="A000123" />
  </ea>
  <k>1</k>
  <h>0</h>
  <o>0</o>
  </firstSelected>
<lastSelected>
  <n>Third element</n>
<a>
  <it>Third element</it>
  <it>3</it>
  <it>3</it>
  <it>1</it>
  <it>A000125</it>
  </a>
<ea>
  <it v="Third element" />
  <it v="3" />
  <it v="3" />
  <it v="1" />
  <it v="A000125" />
  </ea>
  <k>3</k>
  <h>0</h>
  <o>1</o>
  </lastSelected>
  <selectedCount>3</selectedCount>
<schema>
  <k>4294967295</k>
  <vis>1</vis>
  <applyOnlyOnce>0</applyOnlyOnce>
  <onceApplied>0</onceApplied>
  <applyOnRebuild>0</applyOnRebuild>
  </schema>
  </selectionInfo>
  </ChangeDimSelectionResult>
  </soapenv:Body>
  </soapenv:Envelope>

JSON request:

{
"ChangeDimSelection" :
{
"tDim" :
{
"id" : "S1!M!S!S1"
},
"tArg" :
{
"newInstance" : "true",
"setHierarchy" :
{
"id" : "SOURCE1"
},
"elSelectOp" : "Unknown",
"elRelative" : "Unknown",
"next" :
{
"elSelectOp" : "Select",
"elRelative" : "All"
}
}
}
}

JSON response:

{
"ChangeDimSelectionResult" :
{
"id" : "S1!M!S!S6",
"selectionInfo" :
{
"firstSelected" :
{
"n" : "One elemen",
"a" :
{
"it" :
[
"One elemen",
"1",
"1",
"0",
"A000123"
]
},
"ea" :
{
"it" :
[
{
"@v" : "One elemen"
},
{
"@v" : "1"
},
{
"@v" : "1"
},
{
"@v" : "0"
},
{
"@v" : "A000123"
}
]
},
"k" : "1",
"h" : "0",
"o" : "0"
},
"lastSelected" :
{
"n" : "Third element",
"a" :
{
"it" :
[
"Third element",
"3",
"3",
"1",
"A000125"
]
},
"ea" :
{
"it" :
[
{
"@v" : "Third element"
},
{
"@v" : "3"
},
{
"@v" : "3"
},
{
"@v" : "1"
},
{
"@v" : "A000125"
}
]
},
"k" : "3",
"h" : "0",
"o" : "1"
},
"selectedCount" : "3",
"schema" :
{
"k" : "4294967295",
"vis" : "1",
"applyOnlyOnce" : "0",
"onceApplied" : "0",
"applyOnRebuild" : "0"
}
}
}
}
public static ChangeDimSelectionResult ApplyHierarchy(DmId moniker, string hierarchyId)
{
var somClient = new SomPortTypeClient(); //Proxy object for operation execution
//Operation execution parameters
var tSel = new ChangeDimSelection()
{
tArg = new ChangeDimSelectionArg()
{
newInstance = true,
setHierarchy = new DmHierArg() { id = hierarchyId },
//After alternative hierarchy is applied, select all elements
next = new DmSelectionArg()
{
elRelative = DmElRelative.All,
elSelectOp = DmElSelectOp.Select
}
},
tDim = moniker
};
//Apply alternative hierarchy and select elements
var result = somClient.ChangeDimSelection(tSel);
return result;
}

See also:

ChangeDimSelection: Operation