IRdsDictionaryInstance.Insert

Fore Syntax

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

Fore.NET Syntax

Insert(Parent: Integer; Data: Prognoz.Platform.Interop.Rds.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:

Fore 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.

Fore.NET Example

The requirements and result of the Fore.NET Example execution match with those in the Fore Example.

Imports Prognoz.Platform.Interop.Rds;

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    MDMKey: uinteger;
    Dict: IRdsDictionary;
    DictInst: IRdsDictionaryInstance;
    Data: IRdsDictionaryElementData;
    Attr: IRDsAttributes;
    Key: uinteger;
Begin
    MB := Params.Metabase;
    // 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 As uinteger, Data);
End Sub;

See also:

IRdsDictionaryInstance