HierarchyParameterKey: Integer;
The HierarchyParameterKey property determines the parameter key that will be used to select alternative hierarchy.
It is relevant if the HierarchyTypeSource property is set to AltHierarchySourceEnum.FromParam. As a value specify key of the parameter created in the data entry form. The parameter should be based on the dictionary, which structure has an attribute that returns keys of the dictionaries, which are alternative hierarchies for the Dictionary dictionary.
Executing the example requires that the repository contains a data entry form with the DEF_FORM identifier and a dictionary with the DICT_FIRMS identifier. Alternative hierarchies are created for the dictionary. The data entry form should also contain a parameter based on any dictionary with the ALT_KEY attribute in its structure. The values of this attribute should be keys of the dictionaries, which are alternative hierarchies for the DICT_FIRMS dictionary.
Add links to the Dimensions and Metabase system assemblies. Add links to the assemblies required for working with data entry forms.
Sub UserProc;
Var
Mb: IMetabase;
Dict: IMetabaseObjectDescriptor;
DEForm: IDataEntryForm;
Params: IDefParameters;
Param, AltParam: IDefParameter;
Result: IDefParametersApplyResult;
Begin
Mb := MetabaseClass.Active;
// Current data entry form instance
DEForm := New DataEntryForm.CreateByDataEntryForm(Mb.ItemById("DEF_FORM"), True);
// Parameters
Params := DEForm.Parameters;
Params.BeginUpdate;
// Parameter that will be used to select alternative hierarchy
AltParam := Params.Item(0);
// Create a new parameter
Param := Params.Add;
Param.Name := "Company";
Dict := Mb.ItemById("DICT_FIRMS");
Param.Dictionary := New NamedEntity.CreateWithData(Dict.Key, Dict.Name, Dict.Id);
Param.SelectionType := SelectionTypeEnum.Single;
Param.UseDefaultValue := True;
Param.DefaultValueSelection.SelectElement(1, False);
Param.IncludeAllSheets;
// Set up alternative hierarchy for parameter
Param.HierarchyTypeSource := AltHierarchySourceEnum.FromParam;
Param.HierarchyParameterKey := AltParam.Key;
Param.HierarchyParameterAttributeKey := AltParam.DimensionInstance.Dimension.Attributes.FindById("ALT_KEY").Key;
// Apply changes
Result := Params.ApplyChanges;
If Result.Success Then
Debug.WriteLine("Parameter is created without errors")
Else
Debug.WriteLine(Result.Title);
Debug.WriteLine(Result.Message);
Debug.WriteLine("Parameter key: " + Result.ParamKey.ToString);
End If;
DEForm._Dispose;
End Sub UserProc;
After executing the example, the parameter based on the DICT_FIRMS dictionary is created for the data entry form. The alternative hierarchy that will be displayed as value of the new parameter will be selected by means of the existing data entry form parameter.
See also: