Skip to main content

Fields

Fields define the columns that a view exposes. Unlike table fields, view fields do not create physical database columns — they reference columns (or expressions) from the view's underlying data sources. Every field on a view is either bound (mapped directly to a data source column) or computed (defined by a SQL expression generated at sync time).

All view field types inherit from the abstract AxViewField base, which provides common properties such as Name, Label, HelpText, and ConfigurationKey. The concrete type determines whether the field is bound or computed and what additional properties are available.


Field Types

TypeParentDescription
AxViewFieldBoundAxViewFieldMaps to a column on one of the view's data sources. Optionally applies an aggregation function.
AxViewFieldComputedAxViewFieldValue defined by a static method that returns a SQL expression string.
AxViewFieldComputedEnumAxViewFieldComputedComputed field typed to a base enumeration.
AxViewFieldComputedStringAxViewFieldComputedComputed field typed as a string with size and alignment properties.
AxViewFieldComputedDateAxViewFieldComputedComputed field typed as a date.
AxViewFieldComputedIntAxViewFieldComputedComputed field typed as a 32-bit integer.
AxViewFieldComputedInt64AxViewFieldComputedComputed field typed as a 64-bit integer.
AxViewFieldComputedRealAxViewFieldComputedComputed field typed as a decimal/real.
AxViewFieldComputedUtcDateTimeAxViewFieldComputedComputed field typed as a UTC date-time.

Bound Fields

A bound field is the simplest field type. It maps a column from one of the view's data sources into the view's result set. You specify which data source and which field on that data source.

When the view uses grouping (e.g., GROUP BY), bound fields can apply an aggregation function — Sum, Count, Min, Max, or Avg — so the view returns aggregate results rather than individual rows.

Example

A view over CustTable with a bound field AccountNum:

PropertyValue
NameAccountNum
DataSourceCustTable
DataFieldAccountNum
AggregationNone

This produces a SQL column reference like T1.ACCOUNTNUM AS ACCOUNTNUM in the generated view.


Computed Fields

A computed field has no direct mapping to a data source column. Instead, its value is defined by a static method that returns a SQL expression as a str. The framework calls this method during database synchronisation and splices the returned string into the CREATE VIEW statement.

How to Create a Computed Column

  1. Add a computed field to the view's Fields node (right-click → New → Computed Column of the appropriate type).
  2. Create a server static str method on the view class that builds and returns the SQL expression.
  3. Set the field's ViewMethod property to the method name (for methods on the view itself) or Method property to ClassName::MethodName (for methods on an external class).

Using SysComputedColumn

The SysComputedColumn class provides helper methods that generate correct SQL fragments. Always use these helpers rather then writing raw SQL — they handle quoting, escaping, and database-agnostic syntax.

/// <summary>
/// Computes the line amount as Quantity * UnitPrice.
/// </summary>
private static server str lineAmount()
{
DictView dictView = new DictView(tableNum(MyView));
str dsName = identifierStr(SalesLine);

str qty = dictView.computedColumnString(
dsName,
fieldStr(SalesLine, SalesQty),
FieldNameGenerationMode::FieldList);

str price = dictView.computedColumnString(
dsName,
fieldStr(SalesLine, SalesPrice),
FieldNameGenerationMode::FieldList);

return SysComputedColumn::multiply(qty, price);
}

Using DictView

The DictView class is used inside computed column methods to resolve the physical SQL column names for fields in the view's data sources. The computedColumnString() method takes the data source name, the field name, and a generation mode, and returns the aliased column reference (e.g., T1.SALESQTY) that is safe to use in the SQL expression.

warning

Never hard-code physical SQL column names in computed column methods. Always use DictView.computedColumnString() to resolve column references. Physical column names can differ from AOT field names and may change between versions.

Example: Conditional Computed Column

/// <summary>
/// Returns 'Active' or 'Inactive' based on the status field.
/// </summary>
private static server str statusText()
{
DictView dictView = new DictView(tableNum(MyView));
str dsName = identifierStr(CustTable);

str statusField = dictView.computedColumnString(
dsName,
fieldStr(CustTable, Blocked),
FieldNameGenerationMode::FieldList);

return SysComputedColumn::if(
SysComputedColumn::equalExpression(statusField, SysComputedColumn::returnLiteral(0)),
SysComputedColumn::returnLiteral('Active'),
SysComputedColumn::returnLiteral('Inactive'));
}

This generates SQL equivalent to:

CASE WHEN T1.BLOCKED = 0 THEN 'Active' ELSE 'Inactive' END
tip

Computed columns are evaluated at sync time, not per-query. The method runs once during database synchronisation to produce a static SQL expression. You cannot use runtime variables, user context, session state, or table buffer data in computed column methods.


Properties

23/23 properties
PropertyDisplay NameTypeDescription
CommonAxViewField
NameNameStringThe name of the element.
LabelLabelStringDescriptive label for the field, visible to users via Reporting tools.
HelpTextHelp TextStringDescriptive help text for the field, visible to users via Reporting tools.
GroupPromptGroup PromptStringPrompt displayed when the field is part of a field group.
TagsTagsStringTags for this element separated by semicolon.
CountryRegionCodesCountry Region CodesStringComma-separated list of ISO country codes where this field is valid.
CountryRegionContextFieldCountry Region Context FieldStringSpecifies the field used to identify the country context.
ConfigurationKeyConfiguration KeyStringThe configuration key assigned to the field.
RelationContextRelation ContextStringRelation context for the field.
AccessModifierAccess ModifierFieldAccessModifierAccess modifier for the field. Values: Private (0), Public (1), Internal (2).
AosAuthorizationAOS AuthorizationNoYesWhether the field is protected by field-level security. Values: No (0), Yes (1).
IsObsoleteIs ObsoleteNoYesDetermines whether the field is deprecated. Values: No (0), Yes (1).
FeatureClassFeature ClassStringThe feature class used to determine the state of the feature assigned to this field.
BoundAxViewFieldBound
DataSourceData SourceStringThe data source containing the field.
DataFieldData FieldStringThe field on the data source to map.
AggregationAggregationAggregationAggregation function applied to the field. Values: None (0), Min (1), Max (2), Avg (3), Count (4), Sum (5).
ComputedAxViewFieldComputed
MethodMethodStringFully qualified ClassName::MethodName of the static method that returns the SQL expression.
ViewMethodView MethodStringName of a method defined on the view itself that returns the SQL expression.
ExtendedDataTypeExtended Data TypeStringEDT that corresponds to the data in this computed field. Enables richer formatting.
IsVirtualIs VirtualNoYesWhether the computed column is virtual. Values: No (0), Yes (1).
Computed EnumAxViewFieldComputedEnum
EnumTypeEnum TypeStringThe enumeration type used to display the field value. Mutually exclusive with ExtendedDataType.
Computed StringAxViewFieldComputedString
StringSizeString SizeInt32Maximum number of characters allowed. Values larger than this are truncated.
AdjustmentAdjustmentAdjustmentWhether the field value is left or right aligned when displayed. Values: Left (0), Right (1).