Attribute: IRdsAttribute;
The Attribute property determines the linked attribute of the given MDM dictionary.
Executing the example requires the MDM repository NSI_1 that contains MDM dictionaries with the Dict_1 and Dict_2 identifiers. The unique GUID identifier must be available in elements for the second dictionary.
Sub Main;
Var
MB: IMetabase;
MObj: IMetabaseObject;
Dict, Dict2: IRdsDictionary;
Attrs: IRdsAttributes;
LinkAttr, LookupAttr: IRdsAttribute;
Link: IRdsLink;
Begin
MB := MetabaseClass.Active;
MObj := MB.ItemByIdNamespace("Dict_1", MB.ItemById("NSI_1").Key).Edit;
Dict := MObj As IRdsDictionary;
Dict2 := MB.ItemByIdNamespace("Dict_2", MB.ItemById("NSI_1").Key).Bind As IRdsDictionary;
//Attributes of the first dictionary
Attrs := Dict.Attributes;
//Attribute to link with the dictionary
LinkAttr := Attrs.Add;
LinkAttr.DataType := DbDataType.Integer;
LinkAttr.Id := "LinkAttr";
LinkAttr.Name := Attribute to link;
//Link with the dictionary
Link := Dict.Links.Add;
Link.Attribute := LinkAttr;
Link.Reference := Dict2.Attributes.Key;
Link.Id := "Link";
Link.Name := Link with the dictionary Dict_2;
//Imported attribute GUID
LookupAttr := Attrs.Add;
LookupAttr.Id := "Dict2_GUID";
LookupAttr.Name := "GUID";
LookupAttr.Link := Link;
LookupAttr.Lookup := Dict2.Attributes.GUID;
MObj.Save;
End Sub Main;
After executing the example the attribute used to link with the Dict_2 dictionary is created in the first dictionary. The link is established by the Key attribute, then the imported attribute that refers to the GUID attribute of the second dictionary is created in the first dictionary.
See also: