DefaultExpression: IExpression;
DefaultExpression: Prognoz.Platform.Interop.ForeSystem.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.
The requirements and result of the Fore.NET Example execution match with those in the Fore Example.
Add also link to the ForeSystem system assembly.
Imports Prognoz.Platform.Interop.Dal;
Imports Prognoz.Platform.Interop.ForeSystem;
Imports Prognoz.Platform.Interop.Rds;
…
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
Dict: IRdsDictionary;
Attributes: IRdsAttributes;
Attribute: IRdsAttribute;
Exp: IExpression;
Begin
// Get current repository
mb := Params.Metabase;
// 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.ddtString;
// Set possibility to edit attribute value
Attribute.VisibleForEdit := TriState.tsOnOption;
// Set default value
Exp := Attribute.DefaultExpression;
Exp.AsString := "NAME";
// Set calculation of default value each time when changing the element
Attribute.DefaultExpressionKind := RdsAttributeDefaultExpressionKind.radeEvaluateOnEdit;
// Save changes in the MDM dictionary
(Dict As IMetabaseObject).Save();
End Sub;
See also: