DefaultExpression: IExpression;
The DefaultExpression property determines an expression by which default attribute value is determined.
For expression as symbol string use the property IExpression.AsString.
Executing the example requires that the repository contains a table MDM dictionary with the ATTRIBUTED identifier.
Add links to the Dal, Metabase and Rds system assemblies.
Sub UserProc;
Var
mb: IMetabase;
Dict: IRdsDictionary;
Attributes: IRdsAttributes;
Attribute: IRdsAttribute;
Exp: IExpression;
Begin
// Get current repository
mb := MetabaseClass.Active;
// Get MDM dictionary
Dict := mb.ItemById("ATTRIBUTED").Edit As IRdsDictionary;
// Get dictionary attributes
Attributes := Dict.Attributes;
// Add a new attribute
Attribute := Attributes.Add;
// Set name and data type of attribute
Attribute.Name := "New attribute";
Attribute.DataType := DbDataType.String;
// Set possibility to edit attribute value
Attribute.VisibleForEdit := TriState.OnOption;
// Set default value
Exp := Attribute.DefaultExpression;
Exp.AsString := "NAME";
// Set calculation of default value each time when changing the element
Attribute.DefaultExpressionKind := RdsAttributeDefaultExpressionKind.EvaluateOnEdit;
// Save changes in the MDM dictionary
(Dict As IMetabaseObject).Save;
End Sub UserProc;
After executing the example, the attribute is added to the dictionary and the expression to calculate it default value is set. Value will be calculated each time on changing element.
See also: