HierarchyDictKey: Integer;
The HierarchyDictKey property determines the dictionary key that will be used as an alternative hierarchy.
It is relevant if the HierarchyTypeSource property is set to AltHierarchySourceEnum.FromDictionary. As a property value specify the dictionary key, based on which an alternative hierarchy is created for the dictionary specified in the Dictionary property.
Executing the example requires that the repository contains a data entry form with the DEF_FORM identifier and two dictionaries with the DICT_FIRMS and ALT_DICT_FIRMS identifiers. The ALT_DICT_FIRMS dictionary is used as a basis for creating the alternative hierarchy 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: 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;
// 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.FromDictionary;
Param.HierarchyDictKey := Mb.GetObjectKeyById("ALT_DICT_FIRMS");
// 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. Alternative hierarchy elements of ALT_DICT_FIRMS will be displayed as parameter values.
See also: