Create(ObjectKey: Integer; DictionaryKey: Integer; ElementKey: Integer);
Create(ObjectKey: UInteger; DictionaryKey: UInteger; ElementKey: Integer);
ObjectKey. Key of the object, for which a dependencies template is created.
DictionaryKey. Key of the MDM dictionary containing the ElementKey element.
ElementKey. Key of the MDM dictionary element, on which the ObjectKey object depends.
The Create constructor creates a new dependencies template in accordance with specified object parameters, MDM dictionary and dictionary element.
To get object keys and a dictionary it is necessary to use the IMetabaseObjectDescriptor.Key property or the IMetabase.GetObjectKeyById method. To get an element key use the IRdsDictionaryElement.Key, or IRdsDictionaryElements.Element property.
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. The object supports tracking of dependencies on the elements of dictionaries. 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;
//Change settings for using of monitoring dependencies for an object
Obj := Obj.EditDescriptor;
Obj.ElementDependenciesTrackingType := MbElementDependenciesTrackingType.Dependecies;
Obj.SaveDescriptor;
//Change settings to use tracking of references to elements ofnbsp;thenbsp;dictionary
Dictionary := Dictionary.EditDescriptor;
Dictionary.ElementDependenciesTrackingType := MbElementDependenciesTrackingType.Dependents;
Dictionary.SaveDescriptor;
//New template for adding thenbsp;dependency
//Template is created to check the first element of the MDM dictionary
Template := New MbElementDependencyTemplateClass.Create(
Obj.Key, Dictionary.Key, Elements.Element(1));
//A collection of object dependencies
Depends := Obj.ElementDependencies;
Depends.Add(Template);
Mb.ElementDependenciesDatabase.Update(Depends);
End Sub UserProc;
After executing this example the function of tracking of the dependencies on the elements of the dictionary is activated for the specified object and for the MDM dictionary. A new dependency from the first element of a dictionary will be created for an object. A list of dependencies is saved in the repository base.
See also: