Working with MDM Dictionary Data

The user works with MDM dictionary data using properties and methods available in the IRdsDictionaryInstance interface.

To access data, it is necessary to open an MDM dictionary and cast it to the IRdsDictionaryInstance interface:

Sub Main;

Var

MB: IMetabase;

Dict: IRdsDictionary;

DictInst: IRdsDictionaryInstance;

Begin

MB := MetabaseClass.Active;

Dict := MB.ItemByIdNamespace("Dict_1", MB.ItemById("NSI_1").Key).Bind As IRdsDictionary;

DictInst := Dict.Open(Null) As IRdsDictionaryInstance;

End Sub Main;

Cast the opened MDM dictionary to the IDimInstance interface to use functions of search by the values of element attributes and to work with an iterator, and so on.

Sub Main;

Var

MB: IMetabase;

DictInst: IRdsDictionaryInstance;

Inst: IDimInstance;

Elems: IDimElements;

ElemArr: IDimElementArray;

Iter: IDimIterator;

Begin

MB := MetabaseClass.Active;

DictInst := MB.ItemByIdNamespace("Dict_1", MB.ItemById("NSI_1").Key).Open(Null) As IRdsDictionaryInstance;

Inst := DictInst As IDimInstance;

Elems := Inst.Elements;

ElemArr := Inst.RootElements;

Iter := ElemArr.Iterator;

While Iter.Next Do

Debug.WriteLine(Elems.Name(Iter.Element));

End While;

End Sub Main;

After executing the example names of all MDM dictionary root elements are displayed in the development environment console. Iterator of standard dictionaries is used to work with elements.

NOTE. Remember that cached data is used when directly casting to the IDimInstance interface. Use the CreateDimInstance method if it is necessary to get a set of data based on the actual set of elements (for example, data of elements after elements collection is changed during form execution).

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);

Var

DictInst: IRdsDictionaryInstance;

Inst: IDimInstance;

Elems: IDimElements;

ElemArr: IDimElementArray;

Iter: IDimIterator;

Begin

DictInst := RdsDictionaryBox1.Source.Instance;

Inst := DictInst.CreateDimInstance;

Elems := Inst.Elements;

ElemArr := Inst.RootElements;

Iter := ElemArr.Iterator;

While Iter.Next Do

Debug.WriteLine(Elems.Name(Iter.Element));

End While;

End Sub Button1OnClick;

After executing the example names of all MDM dictionary root elements displayed in the RdsDictionaryBox1 component are displayed in the console window. Iterator of standard dictionaries is used to work with elements.

See also:

Examples