MbElementDependentTemplateClass.CreateByDictionary

Syntax

CreateByDictionary(DictionaryKey: Integer);

Parameters

DictionaryKey. MDM dictionary key.

Description

The CreateByDictionary constructor creates a new dependencies template in accordance with MDM dictionary parameters.

Comments

To get object and dictionary keys, 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 two objects with the Obj_1 and Obj_2 identifiers and a table MDM dictionary with the Dict_1 identifier.

Add links to the Metabase, Rds system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    Dictionary: IMetabaseObjectDescriptor;
    Elements: IRdsDictionaryElements;
    Depends: IMbElementDependents;
    Template: IMbElementDependentTemplate;
    ObjKeys: Array 
Of Integer;
Begin
    MB := MetabaseClass.Active;
    Dictionary := MB.ItemById(
"Dict_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.CreateByDictionary(Dictionary.Key);
    Template.ElementKey := Elements.Element(
1);
    ObjKeys := 
New Integer[2];
    ObjKeys[
0] := Mb.GetObjectKeyById("Obj_1");
    ObjKeys[
1] := Mb.GetObjectKeyById("Obj_2");
    Template.ObjectKeys := ObjKeys;
    
// 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. New dependencies from the specified objects will be created for the first element. The list of dependencies will be saved in the repository database.

See also:

MbElementDependentTemplateClass