IRdsDictionaryInstance.Insert

Syntax

Insert(Parent: Integer; Data: IRdsDictionaryElementData): Integer;

Parameters

Parent. Parent element key.

Data. Data of the added element.

Description

The Insert method inserts a new element to the dictionary according to the specified parameters.

Comments

The Parent parameter may take a special value:

Example

Executing the example requires that the repository contains an MDM repository with the MDM_REPOSITORY identifier containing an MDM dictionary with the MDM_DICTIONARY identifier. This dictionary should have only system attributes.

Add links to the Metabase, Rds system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    MDMKey: Integer;
    Dict: IRdsDictionary;
    DictInst: IRdsDictionaryInstance;
    Data: IRdsDictionaryElementData;
    Attr: IRDsAttributes;
    Key: Integer;
Begin
    MB := MetabaseClass.Active;
    // Get MDM repository
    MDMKey := MB.ItemById("MDM_REPOSITORY").Key;
    // Get MDM dictionary
    Dict := MB.ItemByIdNamespace("MDM_DICTIONARY", MDMKey).Bind As IRdsDictionary;
    DictInst := Dict.Open(Null);
    // Create a new dictionary element
    Data := DictInst.CreateElementData;
    Attr := Dict.Attributes;
    Data.Attribute(Attr.Name.Key) := "New element";
    // Insert element to the dictionary
    Key := DictInst.Insert(-2, Data);
End Sub UserProc;

After executing the example a new element is added to the MDM dictionary root after all existing elements. The Key variable contains key value of the added element.

See also:

IRdsDictionaryInstance