MbElementDependentTemplateClass.Create

Syntax

Create(ObjectKey: Integer; DictionaryKey: Integer; ElementKey: Integer);

Parameters

ObjectKey. Key of the object, on which the ElementKey element will depend.

DictionaryKey. Key of the MDM dictionary containing the ElementKey element.

ElementKey. Key of the MDM dictionary element, which will depend on the ObjectKey object.

Description

The Create constructor creates a new dependencies template in accordance with specified object parameters, MDM dictionary and dictionary element.

Comments

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 property or the IRdsDictionaryElements.Element property.

Example

Executing the example requires that the repository contains an object with the Obj_1 identifier and a table MDM dictionary with the Dict_1 identifier.

Add links to the Metabase, Rds system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    Obj, Dictionary: IMetabaseObjectDescriptor;
    Elements: IRdsDictionaryElements;
    Depends: IMbElementDependents;
    Template: IMbElementDependentTemplate;
Begin
    MB := MetabaseClass.Active;
    Dictionary := MB.ItemById(
"Dict_1");
    Obj := MB.ItemById(
"Obj_1");
    Elements := (Dictionary.Open(
NullAs IRdsDictionaryInstance).Elements;
    
// Object settings:
    Dictionary := Dictionary.EditDescriptor;
    Dictionary.ElementDependenciesTrackingType := MbElementDependenciesTrackingType.Dependents;
    Dictionary.SaveDescriptor;
    
// New template for adding a dependency
    // Template is created for the first MDM dictionary element
    Template := New MbElementDependentTemplateClass.Create(Obj.Key, Dictionary.Key, Elements.Element(1));
    
// Collection of elements dependencies
    Depends := Dictionary.ElementDependents;
    Depends.Clear;
    Depends.Add(Template);
    Depends.Database.Update(Depends);
    Debug.WriteLine(
"Number of records of MDM dictionary elements dependency on objects: " + Depends.Count.ToString);
End Sub UserProc;

After executing the example a function of monitoring dependencies of dictionary elements on repository objects is enabled for the specified dictionary. A new dependency from the specified object will be created or the first element. The list of dependencies will be saved in the repository database.

See also:

MbElementDependentTemplateClass