SetAttributeValue(Attribute: Integer; Value: Variant; [Options: RdsDictionaryElementDataOptions = 0]);
Attribute. Attribute index, which value is necessary to change.
Value. New attribute value.
Options. Parameters of attribute value change.
The SetAttributeValue method changes the value of a specified element attribute.
The value specified in the Value parameter should have the same type, which the attribute with the Attribute index has. If the attribute takes multiple values, an array of the Variant type is sent to the Value parameter. One of the values that forms multiple value is set in a single array element. If an array consisting of one element is sent to the Value parameter, value of the array element will be used as a single value without taking into account that the array is sent.
To change value of parametric attribute, the Options parameter must equal RdsDictionaryElementDataOptions.AllowChangeParamAttribute.
Executing the example requires an MDM repository with the RDS_REPO identifier that contains a parametric dictionary with the DICT identifier. This dictionary contains an attribute with the PARAM identifier connected with integer parameter.
Add links to the Metabase, Rds system assemblies.
Sub UserProc;
Var
Mb: IMetabase;
RdsKey: Integer;
Dict: IRdsDictionary;
Attrs: IRdsAttributes;
AttrKey, AttrInd: Integer;
ParamsVal: IRdsParamValues;
DictInst: IRdsDictionaryInstance;
Elements: IRdsDictionaryElements;
Element: IRdsDictionaryElement;
Data: IRdsDictionaryElementData;
Begin
Mb := MetabaseClass.Active;
RdsKey := Mb.ItemById("RDS_REPO").Key;
Dict := Mb.ItemByIdNamespace("DICT", RdsKey).Edit As IRdsDictionary;
Attrs := Dict.Attributes;
AttrKey := Attrs.FindById("PARAM").Key;
ParamsVal := Dict.Params.CreateValues;
ParamsVal.FindById("PARAM").Value := 0;
DictInst := Dict.Open(ParamsVal);
Elements := DictInst.Elements;
Element := Elements.Item(1);
Data := Element.Data;
AttrInd := Data.AttributeIndex(AttrKey);
Data.SetAttributeValue(AttrInd, 2, RdsDictionaryElementDataOptions.AllowChangeParamAttribute);
DictInst.Update(Element.Key, Data);
End Sub UserProc;
After executing the example a dictionary is opened with specified parameter values. Then a parameter value is changed for the first element.
See also: