Element: Integer;
The Element property determines a method for fixing dimension selection in calculation formula operands on link deletion.
Executing the example requires that the repository contains a calculation algorithm with the ALGORITHM identifier containing a calculation block. A data consumer and data sources should be selected for the calculation block, they should contain at least two dimensions. A link is set up in the simplified mode for the second dimension.
Add links to the Algo, Dimensions, Metabase system assemblies. Add links to the assemblies required for working with calculation algorithms.
Sub UserProc;
Var
MB: IMetabase;
MObj: IMetabaseObjectDescriptor;
Algo: ICalcObject;
List: ICalcObjectsList;
CalcAlgo: ICalcAlgorithm;
CalcBlock: ICalcObject;
Block: ICalcBlock;
IteratorModel: ICalcBlockIteratorModel;
IteratorStub: ICalcBlockIteratorStub;
IteratorStubs: ICalcBlockIteratorStubs;
DelLink: ICalcBlockIteratorStubDimensionLinks;
DimensionDelLink: ICalcBlockIteratorStubDimension;
Begin
// Get calculation algorithm
MB := MetabaseClass.Active;
MObj := MB.ItemById("ALGORITHM");
Algo := CalcObjectFactory.CreateCalcObject(MObj, True);
CalcAlgo := Algo As ICalcAlgorithm;
// Get list of calculation algorithm objects
List := CalcAlgo.Items;
// Get calculation block
CalcBlock := List.Item(0);
Block := CalcBlock As ICalcBlock;
// Set up links between data source dimensions and data consumer dimensions
IteratorModel := Block.EditIteratorModel;
// Get data sources collection
IteratorStubs := IteratorModel.Stubs;
// Get the first data source
IteratorStub := IteratorStubs.Item(0);
// Get the second dimension, for which link will be deleted
DimensionDelLink := IteratorStub.Dimensions.Item(1);
DelLink := DimensionDelLink.Links;
// Fix the first element of the dimension on deletion, if data source is used in formula
If IteratorStub.HasUsedFormulesForLinkById = True Then
DelLink.Item(0).Element := 0;
End If;
// Delete link of the second dimension of the data source
DelLink.RemoveAt(0);
// Save changes of link parameters
IteratorModel.Save;
// Save calculation block
Block.SaveObject;
End Sub UserProc;
After executing the example the configured link between the second data source dimension and the data consumer dimension is deleted. If when deleting the link the data source is used in calculation formula, the first element used as a dimension selection will be fixed.
See also: