MbElementDependentTemplateClass.CreateByObject

Syntax

CreateByObject(ObjectKey: Integer);

Parameters

ObjectKey. Key of the repository object, on which MDM dictionary elements will depend.

Description

The CreateByObject constructor creates a new dependencies template in accordance with repository object parameters.

Comments

To create a new dependencies template in accordance with the specified parameters of object, MDM dictionary and dictionary element, use the MbElementDependentTemplateClass.Create constructor.

Example

Executing the example requires MDM dictionaries with the DICT and DICT1 identifiers.

Add links to the Metabase, Rds system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    Obj, Dictionary: IMetabaseObjectDescriptor;
    Elements: IRdsDictionaryElements;
    Depends: IMbElementDependents;
    Template: IMbElementDependentTemplate;
    ElemKeys: Array 
Of Integer;
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.CreateByObject(Obj.Key);
    ElemKeys := 
New Integer[2];
    ElemKeys[
0] := Elements.Element(1);
    ElemKeys[
0] := Elements.Element(2);
    Template.DictionaryKey := Dictionary.Key;
    Template.ElementKeys := ElemKeys;
    
// 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 object will be created for two elements. The list of dependencies will be saved in the repository database.

See also:

MbElementDependentTemplateClass