Click here for general information about scripting in Intrexx.
2. Intrexx Standard Library
In the Velocity script editor,
you can access the Intrexx Standard Library on the
If you select an entry in the library, you can access these buttons at the
bottom right of this area:
Shows the description of the currently selected function with an example script.
Links to the corresponding page that provides more information.
The page that opens also shows the classes, interfaces, methods or properties
that the currently selected function can be used for.
2.1. Application structure
2.1.1. Application info
Information about the application with the stated GUID.
Determine group memberships of the current user and
execute further actions based on this.
#set($groupGuids = ['EF16F15EDA8562E19D7CD56BF2E43001F119193C', '47DD42CF4203EFDC7B1596E0158BB5B1E810D583'])
#set($userMembership = $Portal.getOrgStructure().getMembershipSets($User))
##Returns true, if $User is member of at least one group, which is defined by its guid in $groupGuids
##Not implemented yet
In the following, the Velocity context object "$CalcUtil" for calculating
values will be presented and explained using code examples.
complex calculation and comparison operations can be performed.
The '( )' brackets can be used to structure the operation.
The values for the calculation and comparison operations being performed
can be read from data fields, sessions, requests, table cells or SharedStates.
The following operators are available in a calculation formula:
< (Comparison: Smaller than)
> (Comparison: Greater than)
<= (Comparison: Smaller than or equal to)
>= (Comparison: Greater than or equal to)
== (Comparison: Equal)
!= (Comparison: Unequal)
&& (Logical connection: And)
|| (Logical connection: Or)
! (Logial operator: Not)
126.96.36.199. Other type categories and methods
In addition to the operators described above, there are additional options to call certain variables or methods in formulae:
Value from a data field
Value from a data field as a number
Value from an existing session of the currently logged-in user
Value from an existing session of the currently logged-in user as a number
Value from the current processing context
Value from the current processing context as a number
Value from the current request as a number
For the types with the suffix "AsNumber", Intrexx will attempt to cast the
incoming values, provided it is technically possible.
Without this cast, an exception will occur when you use string data fields, for
example. The Boolean values "true" and "false" will be cast accordingly
to 1 and 0, respectively. It is also possible to state a fallback as a
second method parameter. This fallback is used if the first parameter
is null or empty. This fallback value can also be a formula.
//returns -1, if access to the SharedState variable
"sharedStateValue" returns null or the value is not defined.
//returns 5, if access to the request variable "rq_custom" returns null
or the value is not defined.
//returns 0, if the data field contains null or has not been defined.
188.8.131.52. Error handling
To catch potential errors (e.g. dividing by 0), the following methods
can be used in a formula:
Returns 0 in the case of error
zeroOnError(10/0) == 0
Returns 1 in the case of error
oneOnError(10/0) == 1
Returns the fallback value in the case of error
fallbackOnError(10/0, 2) == 2
184.108.40.206. Rounding functions
Number values can be rounded in formulae. The parameter "scale" describes
the number of decimal places.
Round half away from zero
Corresponds to roundLong
Round half away from zero to the number (scale) of decimal places
(roundLong corresponds to round(0))
Corresponds to round(scale)
220.127.116.11. Case differentiation
Conditions in formulae can be checked in advance with case differentiation,
and based on their result, certain formulae or values can be used.
case(<booleanExpression>, <Formula for true>, <Formula for false>)
The following rules are available for the Boolean expression:
null == false
leer == false
0 == false
false == false
!true == false
!false == true
1 == true
If logical operators are used for the calculation, false becomes 0 and true
becomes 1. This results in the following:
5 > 0 + 0 > -1 == 2
The calculation call with the function "calculate()" on view pages always has
$ProcessingContext - The current processing context. Value is always fixed.
The current data range - $DC for tables and view pages.
Formula - Formula of choice consisting of the methods and operators
Simple addition of two values
Here is a simple example for adding values from data fields.
To address a data field, you can either state its GUID or the name
of the control in single quotation marks.
##Parameters to be transferred to the method calculate():
## $ProcessingContext (fixed value)
## '<Control name of the first summand>'
## '<Control name of the second summand>'
$CalcUtil.calculate($ProcessingContext, $DC, 'dataField("integervcontrol1") + dataField("integervcontrol2")')
##Same example but with the data field GUID instead of the control
$CalcUtil.calculate($ProcessingContext, $DC, 'dataField("3BB...5B3") + dataField("C95...950")')
The methods described above can be combined and nested to use values from
different sources (session, request etc.).
## Combination of data field and session value.
$CalcUtil.calculate($ProcessingContext, $DC,'dataField("3BB...5B3") + session("calcutil_example")')
## Combination of data field and request value.
$CalcUtil.calculate($ProcessingContext, $DC, 'dataField("floatcontrol02E5") + requestAsNumber("rq_calcUtil")')
## Less than comparison with request value.
#set($term = '(dataField("B5F472ED66DCA878683B52CE8F979F4F1DDA172B") * 2) + session("calcutil_value") <
$CalcUtil.calculate($ProcessingContext, $DC, $term)
## Case differentiation for request value
#set($term = '(dataField("B5F472ED66DCA878683B52CE8F979F4F1DDA172B") * 2)')
$CalcUtil.calculate($ProcessingContext, $DC, "case(requestAsNumber('rq_calcUtil') <= 100, $term, -1)")
18.104.22.168. Aggregate functions for tables
You can also process values from table columns using "$CalcUtil". The
calculation operations listed in the table below are available for this:
The call of methods for tables always have two parameters:
Access a table - either via the table name or GUID. These are not
the direct name or GUID of the table control but rather the values
of the attribute "tablerecords" for view tables and "shapedtablebase"
for free layout tables. To identify the values, select
Edit menu / Show elements,
while the page with the table is selected in the
Then navigate through the structure of the desired table. You will
find the entry "tablerecords" or "shapedtablebase", respectively.
You can determin the name and GUID of the entry in the respective
Formula with any number of levels. Access column values with
row(<column name>) or rowAsNumber(<column name>).
The values are calculated when the page is opened. If the table
has a navigation element and this is used, the values of the
Velocity statements and calculations are not updated because
they the table is reloaded dynamically via AJAX.
If you want to perform table calculations after navigation within
the table, the corresponding VTL Include (or VM) need to also
be reloaded via AJAX. As a workaround, we recommend creating the
table to be calculated in such a way that navigation is not required.
Calculates the sum of the column values from the data that is displayed on the current page.
Calculates the minimum of the column values from the data that is displayed on the current page.
Calculates the maximum of the column values from the data that is displayed on the current page.
Calculates the number of data records shown on the current page.
Please note that the following methods are computation intensive.
If you have a large amount of data, you may encounter corresponding delays.
Calculates the sum of the column values of all data records.
Calculates the minimum of the column values of all data records.
Calculates the maximum of the column values of all data records.
Calculates the number of all data records.
Please note: If the table does not contain any data, the methods above
will return the number 0.
## Example output of an info text beneath an article table
#set($sum = 'totalSum(table("8E9F10DCB24CBB4B27FF67A3230CE7753521E1B3"), row("integervcontrol3621234C"))')
#set($count = 'totalCount(table("8E9F10DCB24CBB4B27FF67A3230CE7753521E1B3"), row("floatvcontrol256AC41"))')
$CalcUtil.calculate($ProcessingContext, $DC, $count) articles have been ordered with a total value of $CalcUtil.calculate($ProcessingContext, $DC, $sum) €.
Object for accessing a collection of data objects (e.g. the current data record).
##Returns the record ID of the current data record as a string
22.214.171.124. User-defined $DC in emails
Manual initialization of context object $DC (short for
$Loader.getDataCollection()) for using in emails with content generated from
Velocity. With <APP-GUID>, the GUID of the application, which is the
source of the data records to be processed, has to be provided. The following conditions must be met:
Process has to be triggered by a web event
Data record must already exist
Objects (e.g. data fields), that are used in Velocity must be on the target page as a control
Read the value of a control (e.g. value of a view field). Use the name of the control, where the value should be read from, as the parameter.
Within free layout tables tables, use the context object $drRecord instead of $DC.
Read a value from a system data group. The name of the data field that the value
should be read from needs to be stated as a parameter.
Within free layout tables tables, use the context object $drRecord instead of $DC.
Object for file operations such as inserting a file into an Intrexx data group.
##Deletes the file from the data field
##identified by the GUID and the data record identified by the RecID "1".
$FileHelper.deleteFileFromIntrexx($ProcessingContext, "079A397D11EE732857CD1017C3AC6A55D0D112DA", "1")
2.4.8. Read a single value using a prepared database query (with fallback)
Reads a single value from a database query. If the result set is empty, or
the value is null, the fallbackValue is returned.
If the return data type should be defined more precisely, typed method
calls such as executeAndGetScalarBooleanValue(...) can be used.
#set($statement = $PreparedQuery.prepare($DbConnection, "SELECT <COLUMN> FROM DATAGROUP('<DATAGROUP_GUID>') WHERE <CONDITION>"))
##$statement.setString(1, "Example text")
#set($result = $statement.executeAndGetScalarValue(<FALLBACK_VALUE>))
$lastName - Last name of the contact
$firstName - First name of the contact
$mail - Email address of the contact
$mailbox - The user's mailbox that the contact should be added to. If null, the current users mailbox is used.
If additional properties are set or updated with set()-methods after creating the contact, they have to be saved with $contact.save() afterwards.
$start - The tasks start date
$due - The tasks due date
$subject - The tasks subject
$mailbox - The user's mailbox that the task should be added to. If null, the current user's mailbox is used.
##code for condition1
##code for condition2
##code if no condition matches
2.17. For each loop
foreach loop code snippet.
#foreach($element in )
2.18. Define a variable
#set( $id = 1)
#set( $userName = "Administrator")
#set($variable = aValue)
2.19. Output variable in local format
Outputs a variable in the portal's local format. The variable has to be defined in a ValueHolder.
The following types can be used as the RENDERING_TYPE: integer, datetime, date, time, currency, number, boolean, author
## This is necessary: Prevents the response from having line breaks, unwanted outputs, etc.
## You can write your Velocity code here without effecting the response by mistake
## e.g. set a variable
#set($myVar = "Hello client!")
## This may help you: Use a java.util.Map to make JSON formatting easier later.
#set($map = $CollectionFactory.createMap())
## Add everything required into the map with a reliable key.
## This is necessary: Format the response so the server delivers JSON.
## Format the map to be escaped for the JSON string.