CreateByElement(DictionaryKey: Integer; ElementKey: Integer);
CreateByElement(DictionaryKey: UInteger; ElementKey: Integer);
DictionaryKey - a key of MDM dictionary that has the ElementKey element.
ElementKey - a key of an element of MDM dictionary from which objects depend.
The CreateByElement constructor creates a new dependencies template in accordance with specified object parameters of MDM dictionary and dictionary element.
To get a dictionary key it is necessary to use the IMetabaseObjectDescriptor.Key property or the IMetabase.GetObjectKeyById method.
Executing the example requires that the repository contains an object with the Obj_1 identifier and an MDM dictionary with the Country identifier in repository. Monitoring dependencies from elements of MDM dictionary is included for an object. The dictionary is stored in the MDM repository with the RDS identifier.
Sub UserProc;
Var
MB: IMetabase;
Obj, Dictionary: IMetabaseObjectDescriptor;
Elements: IRdsDictionaryElements;
Depends: IMbElementDependencies;
Template: IMbElementDependencyTemplate;
Begin
MB := MetabaseClass.Active;
Obj := MB.ItemById("Obj_1");
Dictionary := MB.ItemByIdNamespace("Country", MB.ItemById("RDS").Key);
Elements := (Dictionary.Open(Null) As IRdsDictionaryInstance).Elements;
Template := New MbElementDependencyTemplateClass.CreateByElement(
Dictionary.Key, Elements.Element(1));
//A collection of object dependencies
Depends := Obj.ElementDependencies;
Depends.Add(Template);
Mb.ElementDependenciesDatabase.Update(Depends);
End Sub UserProc;
On executing the example a collection of object dependencies from elements of MDM dictionary will be obtained. A new dependency from a specified element of a dictionary will be added into a list of dependencies. A list of dependencies is saved in the repository base.
See also: