Calculated fields are defined as field elements with an additional XML attribute, dataSetExpression, that holds the calculation for the field.
field
The field element is a child of the fieldList element. The location of the fieldList element for calculated fields depends on the location of the fields used in the calculation:
• | Calculated fields where all the columns in the calculation come from a single table appear twice in the design file: |
• | Under the jdbcTable element for the join tree that contains the table. |
• | Under the jdbcTable or jdbcQuery element for that table. |
• | Calculated fields that use columns from different tables appear only once, under the jdbcTable element for the join tree contains both tables. Remember, it is not possible to create calculated fields from columns in different join trees. |
• | Constant fields appear under resources as a null element. |
Constant fields are calculated fields that do not reference any column names. Constant fields are defined as field elements in a fieldList under the null element. Because constant fields are not dependent on any column values, they may be used in any join tree or data island. They can also be used in other calculated fields and pre-filters.
XML Attributes
Attribute | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
dataSetExpression | String | (Required) Expression that calculates a value. This value is either based on other columns or is a constant value. For a description of the syntax for the expression, including how to reference columns, see Domain Expression Language (DomEL). For information on using attributes in calculated fields, see Using Server Attributes in Design Files. | |||||||||||||||
id | String | (Required) Identifier for the calculated field. The format of the id depends on how the calculated field appears in the design file:
The id XML attribute can contain alphanumeric characters along with any combination of the following: @#$^`_~? It cannot start with a digit. | |||||||||||||||
type | String | The Java type of the value calculated by the expression, for example java.lang.String. This type must be compatible with the result of the DomEL expression and among the JDBC-compatible types listed in Supported Types. |
Example
The following example shows the XML for a calculated expression that only references one table, the accounts table. Because it references only the columns of accounts, it appears in that table and in the join tree.
<jdbcTable datasourceId="SugarCRMDataSource" id="accounts" schemaAlias="public" datasourceTableName="accounts"> <fieldList> ... <field dataSetExpression="concat( billing_address_city, ', ', billing_address_state )" id="city_and_state" type="java.lang.String"/> ... </fieldlist></jdbcTable>...<jdbcTable datasourceId="SugarCRMDataSource" id="JoinTree_1" schemaAlias="public" datasourceTableName="anything"> <fieldList> ... <field dataSetExpression="concat( billing_address_city, ', ', accounts.billing_address_state )" id="accounts.city_and_state" type="java.lang.String"/> ... </fieldlist></jdbcTable>[/code] |
null
The null element is a container for constant fields. null is a child of the resources element.
Child Elements
Element Name | Description |
---|---|
<fieldList> | (Required) A container for the field elements for constant fields. The null element can contain only one fieldlist element. |
fieldList
As a child of null, fieldList is a container for one or more field elements that represent constant fields.
Child Elements
Element Name | Description |
---|---|
<field> | (Required) A constant field. Constant fields may be used in any join tree or data island. They can also be used in other calculated fields and pre-filters. |
Example
The following example shows the XML for two constant calculated fields.
[/code] ...[/code][/code] |
Recommended Comments
There are no comments to display.