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
| Type | Parent | Description |
|---|---|---|
| AxViewFieldBound | AxViewField | Maps to a column on one of the view's data sources. Optionally applies an aggregation function. |
| AxViewFieldComputed | AxViewField | Value defined by a static method that returns a SQL expression string. |
| AxViewFieldComputedEnum | AxViewFieldComputed | Computed field typed to a base enumeration. |
| AxViewFieldComputedString | AxViewFieldComputed | Computed field typed as a string with size and alignment properties. |
| AxViewFieldComputedDate | AxViewFieldComputed | Computed field typed as a date. |
| AxViewFieldComputedInt | AxViewFieldComputed | Computed field typed as a 32-bit integer. |
| AxViewFieldComputedInt64 | AxViewFieldComputed | Computed field typed as a 64-bit integer. |
| AxViewFieldComputedReal | AxViewFieldComputed | Computed field typed as a decimal/real. |
| AxViewFieldComputedUtcDateTime | AxViewFieldComputed | Computed 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:
| Property | Value |
|---|---|
| Name | AccountNum |
| DataSource | CustTable |
| DataField | AccountNum |
| Aggregation | None |
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
- Add a computed field to the view's Fields node (right-click → New → Computed Column of the appropriate type).
- Create a
server static strmethod on the view class that builds and returns the SQL expression. - 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.
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
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
| Property | Display Name | Type | Description |
|---|---|---|---|
| CommonAxViewField | |||
| Name | Name | String | The name of the element. |
| Label | Label | String | Descriptive label for the field, visible to users via Reporting tools. |
| HelpText | Help Text | String | Descriptive help text for the field, visible to users via Reporting tools. |
| GroupPrompt | Group Prompt | String | Prompt displayed when the field is part of a field group. |
| Tags | Tags | String | Tags for this element separated by semicolon. |
| CountryRegionCodes | Country Region Codes | String | Comma-separated list of ISO country codes where this field is valid. |
| CountryRegionContextField | Country Region Context Field | String | Specifies the field used to identify the country context. |
| ConfigurationKey | Configuration Key | String | The configuration key assigned to the field. |
| RelationContext | Relation Context | String | Relation context for the field. |
| AccessModifier | Access Modifier | FieldAccessModifier | Access modifier for the field. Values: Private (0), Public (1), Internal (2). |
| AosAuthorization | AOS Authorization | NoYes | Whether the field is protected by field-level security. Values: No (0), Yes (1). |
| IsObsolete | Is Obsolete | NoYes | Determines whether the field is deprecated. Values: No (0), Yes (1). |
| FeatureClass | Feature Class | String | The feature class used to determine the state of the feature assigned to this field. |
| BoundAxViewFieldBound | |||
| DataSource | Data Source | String | The data source containing the field. |
| DataField | Data Field | String | The field on the data source to map. |
| Aggregation | Aggregation | Aggregation | Aggregation function applied to the field. Values: None (0), Min (1), Max (2), Avg (3), Count (4), Sum (5). |
| ComputedAxViewFieldComputed | |||
| Method | Method | String | Fully qualified ClassName::MethodName of the static method that returns the SQL expression. |
| ViewMethod | View Method | String | Name of a method defined on the view itself that returns the SQL expression. |
| ExtendedDataType | Extended Data Type | String | EDT that corresponds to the data in this computed field. Enables richer formatting. |
| IsVirtual | Is Virtual | NoYes | Whether the computed column is virtual. Values: No (0), Yes (1). |
| Computed EnumAxViewFieldComputedEnum | |||
| EnumType | Enum Type | String | The enumeration type used to display the field value. Mutually exclusive with ExtendedDataType. |
| Computed StringAxViewFieldComputedString | |||
| StringSize | String Size | Int32 | Maximum number of characters allowed. Values larger than this are truncated. |
| Adjustment | Adjustment | Adjustment | Whether the field value is left or right aligned when displayed. Values: Left (0), Right (1). |