MbElementDependencyTemplateClass.Create

Fore Syntax

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

Fore.NET Syntax

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

Parameters

ObjectKey - an object key, for which dependencies template is created.

DictionaryKey - a key of MDM dictionary that has the ElementKey element.

ElementKey - a key of an element of MDM dictionary from which an object ObjectKey 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, or IRdsDictionaryElements.Element property.

Fore Example

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(NullAs 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
    //A pattern is created for the first element of 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:

MbElementDependencyTemplateClass