MbElementDependencyTemplateClass.Create

Syntax

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

Parameters

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.

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 an MDM dictionary with the Country identifier. 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(NullAs IRdsDictionaryInstance).Elements;
    //Change settings to use tracking of dependencies for an object
    Obj := Obj.EditDescriptor;
    Obj.ElementDependenciesTrackingType := MbElementDependenciesTrackingType.Dependecies;
    Obj.SaveDescriptor;
    //Change settings to use tracking of references to elements of the dictionary
    Dictionary := Dictionary.EditDescriptor;
    Dictionary.ElementDependenciesTrackingType := MbElementDependenciesTrackingType.Dependents;
    Dictionary.SaveDescriptor;
    //New template for adding a dependency
    //Template is created for 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 the example the function of tracking the dependencies from the dictionary elements is enabled for the specified object and MDM dictionary. A new dependency from the first dictionary element will be created for an object. The list of dependencies will be saved in the repository database.

See also:

MbElementDependencyTemplateClass