Calculation field: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 8: Line 8:
== Variables ==
== Variables ==
Variables are values of other fields in the same record.<br />
Variables are values of other fields in the same record.<br />
Variable must be enclosed by a pound sign and open brace #{ and a closed brace }. i.e. expression
Variable must be enclosed by a pound sign and open brace #{ and a closed brace }. i.e. expression:
<source lang="java">
<source lang="java">
"#{field_name1} + #{field_name2}"
#{field_name1} + #{field_name2}
</source>
</source>


Line 17: Line 17:
'Result: ' + '#{string_field1}' + '#{string_field2}'
'Result: ' + '#{string_field1}' + '#{string_field2}'
</source>
</source>
== Operators ==
The following operators are supported:
* ( open parentheses
* ) closed parentheses
* + addition (for numbers and strings)
* - subtraction
* * multiplication
* / division
* % modulus
* == equal (for numbers and strings)
* != not equal (for numbers and strings)
* < less than (for numbers and strings)
* <= less than or equal (for numbers and strings)
* > greater than (for numbers and strings)
* >= greater than or equal (for numbers and strings)
* && boolean and
* || boolean or
* ! boolean not
== Result type ==
For each calculation, there must be a correct result type set:
* ''Real result'' and ''Integer result'' are used for expressions with numerical result.
* ''Date/Time result'' is used to represent the result in form of date and time. The calculation result is interpreted as the number of seconds that has passed since January 1, 1970 (UNIX time).
* ''Date result'' is the same as the previous type, but displays only the date.
* ''String result'' is used for expressions that contain string manipulations or functions that return a string.
== Link to entry ==
Use the following syntax to get access to the values of entry fields like Link to entry:
<source lang="java">
#{field_name.child_field_name}
</source>
where field_name – name of field like Link to the entry, child_field_name – name of one field of a related entry.
If a field like Link to the entry contains several links, then use index (starts from zero) to get access to them:
<source lang="java">
#{field_name@0.child_field_name}, #{field_name@1.child_field_name}, …
</source>
You can specify one of the supported aggregation functions instead of the index:
#{field_name@sum.child_field_name} – returns the sum of values of field child_field_name for all entries included into field_name.
In addition, the following functions are supported: avg, min, max.
#{field_name@size} – returns the number of entries in field field_name.