IRdsAttribute.Calculated

Syntax

Calculated: Boolean;

Description

The Calculated property determines whether the attribute is a calculated one.

Comments

Available values:

Text of the query used to calculate attribute value, is defined in the IRdsAttribute.Query property. You cannot set value of a calculated attribute. If the query contains main table fields and borrowed fields, the #TABLE# mask should be used before the main fields.

If the dictionary includes calculated attributes, it is reloaded on adding or editing an element.

Example

Executing the example requires that the repository contains an MDM repository with the RDS identifier that includes an MDM dictionary with the DICT identifier.

Add links to the Metabase, Rds, and Dal system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    RdsKey: Integer;
    MObj: IMetabaseObject;
    Dict: IRdsDictionary;
    Attrs: IRdsAttributes;
    Attr: IRdsAttribute;
Begin
    MB := MetabaseClass.Active;
    RdsKey := MB.GetObjectKeyById("RDS");
    MObj := MB.ItemByIdNamespace("DICT", RdsKey).Edit;
    Dict := MObj As IRdsDictionary;
    Attrs := Dict.Attributes;
    Attr := Attrs.Add;
    Attr.DataType := DbDataType.Integer;
    Attr.Id := "CALC_ATTR";
    Attr.Name := "Calculated attribute";
    Attr.Calculated := True;
    Attr.Query := "#TABLE#.KEY + 1";
    MObj.Save;
End Sub UserProc;

After executing the example a calculated attribute with the CALC_ATTR identifier is added to the MDM dictionary. Attribute value is based on the following formula:element key value + 1.

See also:

IRdsAttribute