CreateElementData: IRdsDictionaryElementData;
The CreateElementData method creates an object that contains data of element attributes of the MDM dictionary.
Executing the example requires that the repository contains an MDM repository with the MDM_REPO identifier. This repository must contain an MDM dictionary with the MDM_DICT identifier. The dictionary contains a Boolean custom attribute with the ACTUAL identifier.
Add links to the Metabase, Rds system assemblies.
Sub UserProc;
Var
MB: IMetabase;
MdmKey: Integer;
Dict: IRdsDictionary;
DictInst: IRdsDictionaryInstance;
Data: IRdsDictionaryElementData;
Attr: IRDsAttributes;
Elements: IRdsDictionaryElements;
Key: Integer;
Begin
MB := MetabaseClass.Active;
MdmKey := MB.ItemById("MDM_REPO").Key;
Dict := MB.ItemByIdNamespace("MDM_DICT", MdmKey).Bind As IRdsDictionary;
// Open MDM dictionary
DictInst := Dict.Open(Null);
DictInst.FetchAll := True;
// Create a dictionary element
Data := DictInst.CreateElementData;
Attr := Dict.Attributes;
Data.Attribute(Attr.Name.Key) := "New element";
Data.Attribute(Attr.FindById("ACTUAL").Key) := True;
Elements := DictInst.Elements;
// Add created element to the dictionary
Key := DictInst.Insert(Elements.Root, Data);
End Sub UserProc;
Example execution result: a new element named New Element is added to the MDM dictionary, value of the ACTUAL attribute is True. The Key variable contains a key of created element.
See also: