Velocity

1. General

With Velocity script, you can expand the functionality of Intrexx. Click here for more information about where the Groovy script editor can be found and used in the Intrexx Portal Manager. The following links provide additional helpful information about using Velocity in Intrexx:
The corresponding, sufficient programming knowhow is required to use Velocity in Intrexx. Please note that United Planet is not liable for errors, loss of data or security flaws that arise as a result of incorrect Velocity scripts.

2. Intrexx Standard Library




In the Velocity script editor, you can access the Intrexx Standard Library on the Libraries tab. If you select an entry in the library, you can access these buttons at the bottom right of this area:

Show description
Shows the description of the currently selected function with an example script.

Open link
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.
Example:
#set($appInfo = $RtCache.getApplication("C6F004594EEA424B2AACCD105181AD7F0660DF6D").getStartFupGuid())
Returns the GUID of the application's start page.
$RtCache.getApplication("")
Interface ApplicationInfo

2.1.2. Data group info

Information about the data group with the stated GUID.
Example:
#set($dgInfo = $RtCache.getDataGroup("93B1A993C5FCF2895C93E1B7BF3BDDC847DC2BCD").getName())
Returns the name of the data group.
$RtCache.getDataGroup("")
Interface DataGroupInfo

2.1.3. Data field info

Information about the data field with the stated GUID.
Example:
#set($fldInfo = $RtCache.getField("8E2B87AE9F9BD1FD2FE38AD6856347F3A0D358AD").getName())
Returns the name of the data field.
$RtCache.getField("")
Interface FieldInfo

2.1.4. Page info

Information about the page with the stated GUID.
Example:
#set($pageInfo = $RtCache.getPage("D867C6B9AC0D17E3F524ED5A5E164463046F8F01")isEditPage())
Returns true if the page is an edit page, otherwise returns false.
$RtCache.getPage("")
Interface PageInfo

2.2. Current user

2.2.1. Login name of current user

Returns the login name of current user.
$User.getLoginName()
Interface IUser

2.2.2. Email address of current user

Returns the email address of current user.
$User.getEmailBiz()
Interface IUser

2.2.3. Determine user memberships

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
#if ($userMembership.intersects($groupGuids))
	##Not implemented yet
#end
Class VelocityOrgStructureWrapper

2.3. Objects in the Velocity context

2.3.1. $AccessController

Class that can be used to check access permissions to applications, data groups etc.
$AccessController
Class IxAccessController

2.3.2. $AsynchronousRequestHandler

Object for processing asynchronous requests.
$AsynchronousRequestHandler
Class AsynchronousRequestHandlerCallable

2.3.3. $BCM

Object for accessing the cache manager and the update sequence number (USN) of individual objects.
##Returns the USN of the transferred view page
$BCM.getUsn("viewpage971CA7D9")
Class BrowserCacheManager

2.3.4. $BpeeFactory

$AsynchronousRequestHandler
Class BpeeFactory

2.3.5. $Browser

Object for requesting browser information.
##Returns the user agent string of the calling browser.
$Browser.getUserAgentId()
Class BrowserCallable

2.3.6. $CalcUtil

2.3.6.1. Introduction

In the following, the Velocity context object "$CalcUtil" for calculating values will be presented and explained using code examples. With the function calculate(), 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.

2.3.6.2. Operators

The following operators are available in a calculation formula:

2.3.6.3. Other type categories and methods

In addition to the operators described above, there are additional options to call certain variables or methods in formulae:

Method Description Example
datafield Value from a data field datafield("C68F6...D3DE7")
datafieldAsNumber Value from a data field as a number datafieldAsNumber("C68F6...D3DE7")
session Value from an existing session of the currently logged-in user session("sessionValue")
sessionAsNumber Value from an existing session of the currently logged-in user as a number sessionAsNumber("sessionValue")
sharedState Value from the current processing context sharedState("sharedStateValue")
sharedStateAsNumber Value from the current processing context as a number sharedStateAsNumber("sharedStateValue")
requestAsNumber Value from the current request as a number requestAsNumber("rq_requestValue")
abs Absolute value abs(-1)

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.
sharedState("sharedStateValue", -1)

//returns 5, if access to the request variable "rq_custom" returns null
or the value is not defined.
requestAsNumber("rq_custom", (10/2))

//returns 0, if the data field contains null or has not been defined.
datafield("C68F6...D3DE7", 0)

2.3.6.4. Error handling

To catch potential errors (e.g. dividing by 0), the following methods can be used in a formula:

Method Description Example
zeroOnError Returns 0 in the case of error zeroOnError(10/0) == 0
oneOnError Returns 1 in the case of error oneOnError(10/0) == 1
fallbackOnError Returns the fallback value in the case of error fallbackOnError(10/0, 2) == 2

2.3.6.5. Rounding functions

Number values can be rounded in formulae. The parameter "scale" describes the number of decimal places.

Method Description
roundLong Round half away from zero
roundLongHalfAwayFromZero Corresponds to roundLong
roundLongHalfEven
roundLongHalfUp
roundLongHalfDown
round(scale) Round half away from zero to the number (scale) of decimal places (roundLong corresponds to round(0))
roundLongHalfAwayFromZero(scale) Corresponds to round(scale)
roundLongHalfEven(scale)
roundLongHalfUp(scale)
roundLongHalfDown(scale)

2.3.6.6. 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: 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

2.3.6.7. Examples

The calculation call with the function "calculate()" on view pages always has three parameters: 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)
## $DC 
## '<Control name of the first summand>'
## <Operator>
## '<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") <
requestAsNumber("rq_calcUtil")')
$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)")

2.3.6.8. 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:
$CalcUtil.calculate($ProcessingContext, $DC, 'sum(table("8E9...1B3"), row("integervcontrol3621234C"))')
$CalcUtil.calculate($ProcessingContext, $DC, 'sum(table("8E9...1B3"), row("integervcontrol3621234C"))')
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.
Method Description
sum Calculates the sum of the column values from the data that is displayed on the current page.
min Calculates the minimum of the column values from the data that is displayed on the current page.
max Calculates the maximum of the column values from the data that is displayed on the current page.
count 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.

Method Description
totalSum Calculates the sum of the column values of all data records.
totalMin Calculates the minimum of the column values of all data records.
totalMax Calculates the maximum of the column values of all data records.
totalCount 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) €.

2.3.7. $Chat

Object for sending and receiving chat messages.
$Chat
Class ChatProxy

2.3.8. $Codec

Object for coding and encoding strings.
$Codec.hexEncodeString("www.intrexx.com", "UTF-8")
$Codec.hexDecodeString("7777772E696E74726578782E636F6D")
Class Codec

2.3.9. $CollectionFactory

Object for creating collections.
$CollectionFactory.createMap()
Class CollectionFactory

2.3.10. $Constants

Object for accessing the constants of a class.
$Constants
Class Constants

2.3.11. $Cookies

Set cookies.
#set($cookie = $Cookies.createCookie("myCookie", "test"))
$Response.addCookie($cookie)
Class Cookies

2.3.12. $DC

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
$DC.getRecId()

2.3.12.1. 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:
#set($template = $Loader.process($ProcessingContext, "<APP_GUID>", "data"))
#set($DC = $Loader.getDataCollection())

2.3.12.2. $DC - Read value of 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.
Example:

#set($value = $DC.getValueHolder('textvcontrol1234').getValue())
#set($value = $DC.getValueHolder('<CONTROL_NAME>').getValue())

2.3.12.3. Read value from a system data group

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.
Example:

#set($value = $DC.getPropertiesVH().get("STR_COLUMN1").getValue()
#set($value = $DC.getPropertiesVH().get("<DATAFIELD_NAME>").getValue()

2.3.13. $DEBUG

Object for inspecting individual objects and elements in more detail.
##Returns detailled information about the current user object.
$DEBUG.inspect($User)
Class ObjectInspector

2.3.14. $defaultLanguage

The default language of the portals.
$defaultLanguage

2.3.15. $DIMHelper

Objects for accessing Office Integration instances
$DIMHelper
Class DIMWrapper

2.3.16. $DataTransferCallable

Object for accessing data transfer connections.
##Returns the JobHistory of the data transfers job with the stated GUID
$DataTransferCallable.getJobsHistory("0460E20ACAC15EDDA0E9B62E1F815D5BFD3F9B8F")
Class DataTransferCallable

2.3.17. $DbUtil

Object for accessing database connections and managing transactions of database operations.
#set($conn = $DbUtil.getConnection("IxSysDb"))
Class DatabaseUtil

2.3.18. $DefaultMaker

$DefaultMaker
Class DefaultMaker

2.3.19. $DistributionControl

Object for accessing distribution controls.
$DistributionControl
Class VCDistributionControl

2.3.20. $DoubletService

Object for searching for duplicates in data records of an application.
$DoubletService
Class DoubletServiceCallable

2.3.21. $drRecord

Object for accessing the current record in a free layout table.
$drRecord
Interface IRow

2.3.22. $DtUtil

Object for date calculations.
$DtUtil
Class DateTimeUtil

2.3.23. $ESC

Present characters that are normally escaped in Velocity.
##Present a hash (#)
$ESC.getH()
Class EscapedCharacters

2.3.24. $Error

Object for analyzing exceptions.
$Error
Class ErrorObject

2.3.25. $ExceptionUtil

Object for throwing exceptions.
$ExceptionUtil.throwException("java.io.FileNotFoundException", "The file stated does not exist.")
Class VelocityExceptionUtil

2.3.26. Objects for Microsoft Exchange

These objects can only be used in conjunction with the Intrexx MediaGateway.

2.3.26.1. $ExchangeCallable

Callable for Exchange authentications.
$ExchangeCallable.getRequiredFields().isPasswordRequired()
Class ExchangeCallable

2.3.26.2. $ExchangeConnectionCallable

Callable for Exchange connections.
$ExchangeConnectionCallable.getConnection()
Class ExchangeConnectionCallable

2.3.26.3. $ExchangeMailboxCallable

Callable for accessing the mailbox of an Exchange user.
##Returns the out-of-office message of the current user.
$ExchangeMailboxCallable.getOutOfOfficeMessage()
Class ExchangeMailboxCallable

2.3.26.4. $ExchangeMessageCallable

Callable for accessing message objects.
##Saves the message with the ID $strMessageId as an EML file in $strDestinationPath.
$ExchangeMessageCallable.saveMessageAsEML($strMessageId, $strDestinationPath)
Class ExchangeMessageCallable

2.3.26.5. $ExchangeItemCallable

Callable for accessing Exchange objects.
##Saves attachments of the with the ID $strMessageId in $strDestinationPath.
$ExchangeItemCallable.saveAttachment($strMessageId, $strDestinationPath)
Class ExchangeItemCallable

2.3.26.6. $ExchangeUserMailboxCallable

Callable for mailbox information of an Exchange user.
$ExchangeUserMailboxCallable.getMailboxInfo()
Class ExchangeUserMailboxCallable

2.3.27. $Factory

Generate or access objects such as users without them having been predefined in the Velocity context.
$Factory
Class ObjectFactory

2.3.28. $FieldFormatter

$FieldFormatter
Class FieldFormatter

2.3.29. $FileHelper

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")
Class VCFileHelper

2.3.30. $FileUtil

Object for analyzing files in a folder hierarchy.
$FileUtil
Class FileUtil

2.3.31. $Filter

Collection of diverse filters for collections used in the Velocity context.
$Filter
Class Filter

2.3.32. $ForumInfo

Object for accessing forum, thread and post information.
$ForumInfo
Class ForumInfo

2.3.33. $FramesetHelper

Object for creating a new URL based on the current request and a list of additional parameters.
$FramesetHelper
Class FramesetHelper

2.3.34. $HelperFactory

Converts the characters <, >, & and " into their corresponding HTML entity.
$HelperFactory
Class HelperFactory

2.3.35. $I18N

Object for accessing language constants.
$I18N
Class LanguageConstantsCallable

2.3.36. $JSON

Auxiliary functions for creating and working with JSON objects.
$JSON
Class JSONUtil

2.3.37. $lang

Current portal language.
$lang

2.3.38. $layout

Name of the current layout.
$layout

2.3.39. $LayoutManager

Access layout information.
$LayoutManager
Class LayoutManagerCallable

2.3.40. $ListBoxControl

Object for accessing drop-down lists.
$ListBoxControl
Class VCListBoxControl

2.3.41. $ListFormatter

Auxiliary functions for formatting lists.
$ListFormatter
Class ListFormatter

2.3.42. $Loader

Processes incoming requests. You can, for example, access the current database connection via the $Loader.
$Loader
Class BuslogicCaller

2.3.43. $Locales

Access regional settings for number and date values.
$Locales
Class VCLocales

2.3.44. $LogAnalyzer

Object for generating application, user and statistic reports.
$LogAnalyzer
Class LogAnalyzer

2.3.45. $MBGallery

Object for processing and copying/moving/deleting images.
$MBGallery
Class Gallery

2.3.46. $MassMailCallable

$MassMailCallable
Class MassMailCallable

2.3.47. $Math

Object for diverse arithmetical operations.
$Math
Class MathUtil

2.3.48. $Menu

Object for accessing the menu structure.
$Menu
Class MenuCallable

2.3.49. $MenuCloud

Object for accessing a menu cloud.
$MenuCloud
Class MenuCloud

2.3.50. $NewsControllerUtil

Object for access news from a newsletter.
$NewsControllerUtil
Class NewsControllerUtil

2.3.51. $ObjectHelper

Object for null objects and ValueHolders.
$ObjectHelper
Class ObjectHelper

2.3.52. $PageLister

Object for accessing application pages.
$PageLister

2.3.53. $PageUtil

Object for accessing controls and data on the view page of a data record.
#set($renderer = $RendererFactory.getDefaultRenderingContext($ProcessingContext, $User, $lang))
#set($page = $PageUtil.process($RenderingContext, $ProcessingContext, $Request.get("rq_AppGuid"), $DC))
The rendering and processing context as well as the GUID of the current application and a DataCollection are required for initialization
$page.getControlNames()
## Example output
## [textvcontrol60C5B1A8, datetimevcontrol88EFC15D, checkvcontrol68B97F7C, integervcontrolE018B980]

$page.getControlGuids()
## Example output
## [4A21CF034953825EE93093E0C8E51C959D193C5F, 4B953139D2E394C42BD20919A2C1CA757EC10A1A]
The variable "$page" can be used to access controls and data fields on the page.

Class PageUtil

2.3.54. $PolicyBrowserFactory

$PolicyBrowserFactory
Class Factory

2.3.55. $PollHelper

Object for requesting poll properties.
$PollHelper
Class PollCallable

2.3.56. $Portal

Object for accessing portal properties (e.g. name).
$Portal
Class Portal
$Portal.getOrgStructure()
Object for accessing the organizational structure of the portal.

Class VelocityOrgStructureWrapper

2.3.57. $PortalLayoutFactory

Object for accessing the portal layout.
$PortalLayoutFactory

2.3.58. $PreparedQuery

Object for creating and performing database requests.
$PreparedQuery
Class DbQuery

2.3.59. $ProcessingContext

Object of the current processing context.
$ProcessingContext
Class BusinessLogicProcessingContext

2.3.60. $QNameFactory

Object for creating a new xsd:QName namespace.
$QNameFactory
Class QNameFactory

2.3.61. $RDFCallable

Object for accessing tags provided in a portal.
$RDFCallable

2.3.62. $Renderer

Object for creating diverse renderers.
$Renderer
Class StandardUtilRendererFactory

2.3.63. $Rendering context

Object for accessing the current, default portal rendering settings.
$Rendering context
Class Rendering context

2.3.64. $Request

Object for setting and reading request variables.
$Request
Class IServerBridgeRequest

2.3.65. $Response

Object for setting and reading properties of an HTTP response.
$Response
Class HttpResponseWrapper

2.3.66. $RtCache

Runtime cache object with information about applications, data groups etc.
$RtCache
Class VelocityRtCache

2.3.67. $SaucMenu

Objects for setting menu permissions in the web CMS.
$SaucMenu
Class SaucMenuPermission

2.3.68. $SearchUtil

Object for search queries.
$SearchUtil
Class SearchUtil

2.3.69. $Session

Access the session of the current user.
$Session
Class Session

2.3.70. $SettingsHelper

Object for reading settings.
$SettingsHelper
Class VCSettingsHelper

2.3.71. $SharedState

Set and read user-defined values in the processing context.
Read a value from the processing context:

$SharedState.get("myVariable")

Write a value to the processing context:

$SharedState.putAt("myVariable", "myValue")
$SharedState.get("<paramName>")
$SharedState.putAt("<paramName>", "<paramValue>")
Class SharedState

2.3.72. $Sort

Auxiliary object for sorting lists.
$Sort
Class Sort

2.3.73. $TextUtil

Auxiliary object for different types of string manipulations.
$TextUtil
Class TextUtil

2.3.74. $TickerMan

Object for accessing the RSS provider.
$TickerMan
Class TickerManager

2.3.75. $Unique

Object for generating unique variables.
$Unique
Class Unique

2.3.76. $UrlBuilder

Object for creating URLS.
$UrlBuilder
Class UrlBuilder

2.3.77. $User

Object for accessing information of the current user.
$User
Class User

2.3.78. $VDiff

Object for displaying diffs of wiki entries.
$VDiff
Class VDiff

2.3.79. $VH

Object for createing ValueHolders.
$VH
Class ValueHolderFactory

2.3.80. $VHHelper

Auxiliary class for reading values in ValueHolders.
$VHHelper
Class VCValueHolderHelper

2.3.81. $VelocityContext

$VelocityContext


Class VelocityUtil

2.3.82. $VelocityUtil

$VelocityUtil
Class VelocityUtil

2.3.83. $Wiki

$Wiki
Class WikiRenderer

2.3.84. $Zebra

Example:
#set($zebra = $Zebra.createZebra("black", "white"))

$zebra.getStripe()
$zebra.getStripe()
$zebra.getStripe()
$zebra.getStripe()
$zebra.getSameStripe()
returns

black
white
black
white
white
$Zebra
Class Zebra
Class ZebraFactory

2.4. Databases

2.4.1. Current database connection

Gets the current system connection to the database.
$DbConnection

2.4.2. Access an external data connection

Access an external data connection.
$DbUtil.getConnection("connectionName")

2.4.3. Get all column names of a data group

Returns a list of column names from the data group with the stated GUID.
#set($fields = $RtCache.getFields())
#set($columnNames = [])

#foreach($field in $fields)
	#if($field.getDataGroupGuid() == "<DG_GUID>")
		#set($bResult = $columnNames.add($field.getColumnName()))
	#end
#end

2.4.4. Prepared statement with SELECT

Executes a SELECT query on a database table.
#set($statement = $PreparedQuery.prepare($DbConnection, "SELECT <COLUMNS> FROM DATAGROUP('<DATAGROUP_GUID>') WHERE <CONDITION>"))
##$statement.setString(1, "Example text")
##$statement.setInt(2, 123)
##$statement.setBoolean(3, true)
#set($rs = $statement.executeQuery())
#foreach($element in $rs)
	##$element.getIntValue(1)
	##$element.getStringValue(2)
	##$element.getBooleanValue(3)
	##$element.getTimestampValue(4)
#end
$rs.close()
$statement.close()
Class DbPreparedStatement

2.4.5. Prepared statement with INSERT

Executes an INSERT query on a database table.
#set($conn = $DbConnection)
#set($statement = $PreparedQuery.prepare($conn, "INSERT INTO DATAGROUP('<DATAGROUP_GUID>') (<COLUMNS>) VALUES ()"))
$DbUtil.transactionEnlistResource($conn)
##$statement.setString(1, "Example text")
##$statement.setInt(2, 123)
##$statement.setBoolean(3, true)
##$statement.setTimestamp(4, $DtUtil.utcNow())
$statement.executeUpdate()
$statement.close()
Class DbPreparedStatement

2.4.6. Prepared statement with UPDATE

Executes an UPDATE query on a database table.
#set($l_conn = $DbConnection)
#set($statement = $PreparedQuery.prepare($l_conn, "UPDATE DATAGROUP('<DATAGROUP_GUID>') SET <COLUMN> = ? WHERE <CONDITION>"))
$DbUtil.transactionEnlistResource($l_conn)
##$statement.setString(1, "strValue")
##$statement.setInt(2, 123)
##$statement.setBoolean(3, true)
##$statement.setTimestamp(4, $DtUtil.utcNow())
$statement.executeUpdate()
$statement.close()
Class DbPreparedStatement

2.4.7. Prepared statement with DELETE

Executes an DELETE query on a database table.
#set($conn = $DbConnection)
#set($statement = $PreparedQuery.prepare($conn, "DELETE FROM DATAGROUP('<DATAGROUP_GUID>') WHERE <CONDITION>"))
$DbUtil.transactionEnlistResource($conn)
##$statement.setString(1, "Example text")
##$statement.setInt(2, 123)
##$statement.setBoolean(3, true)
##$statement.setTimestamp(4, $DtUtil.utcNow())
$statement.executeUpdate()
$statement.close()
Class DbPreparedStatement

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")
##$statement.setInt(2, 123)
##$statement.setBoolean(3, true)
#set($result = $statement.executeAndGetScalarValue(<FALLBACK_VALUE>))
$statement.close()
Class DbPreparedStatement

2.4.9. Determine the database type

Gets the database type of the system connection. Compare the database type with following identifiers: Unsupported system databases:
#set($strType = $DbConnection.getDescriptor().getDatabaseType())

#if($strType.contains("<DATABASE_IDENTIFIER>"))
#end
Class DbPreparedStatement

2.4.10. Timestamp for system values

This variable contains the timestamp of the current transaction and remains unmodified until the end of this transaction.
$CURRENT_TIMESTAMP

2.5. Troubleshooting

2.5.1. Inspect an object

Inspects an object.
$DEBUG.inspect()
Class ObjectInspector

2.5.2. Write info to log file

Writes an INFO entry to the log file that belongs to the execution context of the script.
$DEBUG.info()
Class ObjectInspector

2.5.3. Write warning to log file

Writes a WARN entry to the log file that belongs to the execution context of the script.
$DEBUG.warn()
Class ObjectInspector

2.5.4. Write error to log file

Writes an ERROR entry to the log file that belongs to the execution context of the script.
$DEBUG.error()
Class ObjectInspector

2.5.5. Stopwatch - Start

Starts the stop watch.
${DEBUG.builtinStopwatch.start()}
Class ObjectInspector

2.5.6. Stopwatch - Take split time

Takes the split time of the stopwatch.
${DEBUG.builtinStopwatch.stop()}
Class ObjectInspector

2.5.7. Stopwatch - Restart

Restarts the stopwatch.
${DEBUG.builtinStopwatch.restart()}
Class ObjectInspector

2.6. Portal data

2.6.1. Portal name

Returns the name of the current portal as a string.
$Portal.getPortalName()
Class Portal

2.6.2. Time zone

Gets the portal's default time zone.
$Portal.getTimeZone()
Class Portal

2.6.3. Users online

Returns a list of GUIDs of all logged-in users of the current portal. The parameter true/false defines whether anonymous users are included in the result list.
Example (also returns anonymous users):
$Portal.getUsersOnline(true)
$Portal.getUsersOnline(bIncludeAnonymousUsers)
Class Portal

2.6.4. Active sessions

Gets the number of active portal sessions.
$Portal.getActiveSessionCount()
Class Portal

2.7. Calculate

2.7.1. Add

Adds two integer, float or double values.
$Math.add($value1, $value2)
Class MathUtil

2.7.2. Subtract

Subtracts two integer, float or double values.
$Math.sub($value1, $value2)
Class MathUtil

2.7.3. Multiply

Multiplies two integer, float or double values.
$Math.mult($value1, $value2)
Class MathUtil

2.7.4. Divide

Divides two double values.
$Math.div($value1, $value2)
Class MathUtil

2.7.5. Maximum

Calculates the maximum of two values.
$Math.max($value1, $value2)
Class MathUtil

2.7.6. Minimum

Calculates the minimum of two values.
$Math.min($value1, $value2)
Class MathUtil

2.8. Renderer

2.8.1. Current date

Creates and formats a date according to the specified portal settings.
$DefaultDateTimeRenderer.writeOutput($Response.getWriter(), $DtUtil.now($User.getTimeZone()))

2.8.2. Current date in user-defined format

Creates and formats a date according to a user-defined renderer.
Output in this example (last value defines the calendar week): 21.09.2009 12:14:35 39
#set($dateTimeRenderer = $RendererFactory.createDateTimeRendererWithParameters($RenderingContext, false, false, null, "dd.MM.yyyy HH.mm.ss CW", "", null))
$dateTimeRenderer.writeOutput($Response.getWriter(), $DtUtil.now($User.getTimeZone()))

2.8.3. Rendering context

Access the current rendering context.
$Rendering context
Class Rendering context

2.9. Date

2.9.1. Localize date

Creates and formats a date according to the specified location. Please note: The specified location needs to be defined as a portal language in the portal properties.
$DtUtil.now($User.getTimeZone()).format($Locales.getLocale("en-US").getDateFormat())

2.10. Session

2.10.1. Session ID

Returns the ID of the current session.
$Session.getId()
Class Session

2.10.2. Read session variable

Returns the value of a session variable.
$Session.get(strSessionVar)
Class Session

2.10.3. Write session variable

Writes a session variable.
$Session.get(strSessionVar)
Class Session

2.11. Escaping

2.11.1. $ Dollar sign

Escape for dollar sign.
${ESC.D}
Class EscapedCharacters

2.11.2. # Number sign; hash

Escape for hash sign.
${ESC.H}
Class EscapedCharacters

2.11.3. " Quotation mark

Escape for quotation mark.
${ESC.QUOT}
Class EscapedCharacters

2.11.4. ! Exclamation mark

Escape for exclamation mark.
${ESC.EXCL}
Class EscapedCharacters

2.11.5. \ Backslash

Escape for backslash.
${ESC.BSL}
Class EscapedCharacters

2.11.6. CR Carriage return

Escape for CR carriage return.
${ESC.CR}
Class EscapedCharacters

2.11.7. LF Line feed

Escape for LF line feed.
${ESC.CR}
Class EscapedCharacters

2.11.8. CRLF Line break

Escape for CRLF line break.
${ESC.CR}
Class EscapedCharacters

2.11.9. TAB horizontal tabulation

Escape for TAB horizontal tabulation.
${ESC.TAB}
Class EscapedCharacters

2.12. TextUtil

2.12.1. Convert an array into a string

Converts an array list into a string, using the default delimiter | and escape character 0. To use different delimiter and escape characters, call the function with additional parameters.
Example:
//Using default delimiter and escape characters.
$TextUtil.arrayToString(p_array)
//Using user-defined delimiter and escape characters.
$TextUtil.arrayToString(p_array, "$", "!")
$TextUtil.arrayToString()
Class TextUtil

2.12.2. Convert a string into an array

Converts a string into an array, if the string was previously created using arrayToString(p_myArray) with default delimiter (|) and escape character (0).
Example:
$TextUtil.stringToArray(p_string)
$TextUtil.stringToArray()
Class TextUtil

2.12.3. Split a string

Splits a string to an array using the stated separator.
Example:
$TextUtil.split(p_string, "$")
$TextUtil.split(p_string, p_delimiter)
Class TextUtil

2.12.4. Parse an integer string

Parses an integer string to an integer.
Example:
$TextUtil.parseInt("1234")
$TextUtil.parseInt()
Class TextUtil

2.12.5. Parse a float string

Parses a float string to an integer.
Example:
$TextUtil.parseFloat("1234.56F")
$TextUtil.parseFloat()
Class TextUtil

2.12.6. Parse a double string

Parses a double string to a double.
Example:
$TextUtil.parseDouble("1234.56")
$TextUtil.parseDouble()
Class TextUtil

2.13. ValueHolder

2.13.1. Create a ValueHolder

Creates a ValueHolder from the given object.
$VH.getValueHolder($object)
Class ValueHolderFactory

2.13.2. Create a ValueHolder with the current date

Creates a ValueHolder with the current date.
$VH.getNowValueHolder()
Class ValueHolderFactory

2.14. Versioning

2.14.1. Display semantic version information of an application

Example:
#set ($version = $Portal.getApplicationVersionInformation("8D3B7A6462649864241A4534FD48364AF378218A").getCurrentVersion())
$version.getFormattedVersion() $version.getDescriptions().get("de") $version.getMajorVersion() $version.getMinorVersion() $version.getPatchVersion() $version.getPreReleaseVersion() $version.getCustomVersion() $version.getDate() $version.getMinProductVersion() $version.getAdditionalRequirements().get("de")
$Portal.getApplicationVersionInformation("")
Class Portal

2.14.2. Display semantic version information of a process

Example:
#set ($version = $Portal.getWorkflowVersionInformation("B239068CECAA616964F71825C2CB9DB74DBB1BBA").getCurrentVersion())
$version.getFormattedVersion()
$version.getDescriptions().get("de")
$version.getMajorVersion()
$version.getMinorVersion()
$version.getPatchVersion()
$version.getPreReleaseVersion()
$version.getCustomVersion()
$version.getDate()
$version.getMinProductVersion()
$version.getAdditionalRequirements().get("de")
$Portal.getWorkflowVersionInformation("")
Class Portal

2.14.3. Display semantic version information of a layout

Example:
#set ($version = $Portal.getLayoutVersionInformation("Beispiellayout").getCurrentVersion())
$version.getFormattedVersion()
$version.getDescriptions().get("de")
$version.getMajorVersion()
$version.getMinorVersion()
$version.getPatchVersion()
$version.getPreReleaseVersion()
$version.getCustomVersion()
$version.getDate()
$version.getMinProductVersion()
$version.getAdditionalRequirements().get("de")
$Portal.getLayoutVersionInformation("")
Class Portal

2.15. Connector for Microsoft Exchange

2.15.1. Current Exchange connection

Returns the current Exchange connection.
#set($conn = $ExchangeConnectionCallable.getConnection())
Class ExchangeConnectionCallable

2.15.2. Folder information

Returns information about an Exchange folder (the inbox folder in this example)
#set($inbox = $ExchangeMailboxCallable.getInboxFolderHref($strMailboxName))
$ExchangeMailboxCallable.getFolderInfoByHref($inbox)
Class ExchangeMailboxCallable

2.15.3. Mailbox name of the current Exchange user

Returns the mailbox name of the current Exchange user.
#set($strMailboxName = $ExchangeUserMailboxCallable.getMailboxInfo().getMailboxName())
Class ExchangeUserMailboxInfo

2.15.4. Account of the current Exchange user

Returns the account connected to the current Exchange connection.
#set($account = $ExchangeUserMailboxCallable.getMailboxInfo().getUserAccount())
Class ExchangeAccount

2.15.5. Set the out of office messsage

Writes the out of office message and sets its status to active. The text is set for internal and external out of office messages.
#set($strMessage = "Out of office till 2010/12/31")
$ExchangeMailboxCallable.setOutOfOfficeMessage($strMessage)
$ExchangeMailboxCallable.setOutOfOffice(true) 
Class ExchangeMailboxCallable

2.15.6. Mark a messsage as read

Marks the message with the stated ID as read.
Example usage (e.g. on an email view page):
$ExchangeMessageCallable.setMessageRead($DC.getRecId())
$ExchangeMessageCallable.setMessageRead($messageId)
Class ExchangeMessageCallable

2.15.7. Message attachments

Returns the attachments of the mail with the stated ID.
Example usage (e.g. on an email view page):
$ExchangeItemCallable.getAttachments($DC.getRecId())
$ExchangeItemCallable.getAttachments($messageId)
Class ExchangeItemCallable

2.15.8. Create an Exchange appointment

Creates an appointment for the current user.

Parameters:
$startDate - Start date of the appointment
$endDate - End date of the appointment
$subject - Subject of the appointment
$body - Description of the appointment

If additional properties are set or updated with set()-methods after creating the appointment, they have to be saved with $appointment.save() afterwards.

Example:
#set($appointment = $ExchangeAppointmentCallable.createNewAppointment($startDate, $endDate, $subject, $body))

$appointment.setLocation("Konferenzraum")
$appointment.save()
#set($appointment = $ExchangeAppointmentCallable.createNewAppointment($startDate, $endDate, $subject, $body))
Class ExchangeAppointmentCallable

2.15.9. Create an Exchange contact

Creates a new contact for the current user.

Parameters:
$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.

Example:
#set($contact = $ExchangeContactCallable.createNewContact($lastName, $firstName, $mail, $mailbox))

$contact.setJobTitle("Developer") $contact.save()
#set($contact = $ExchangeContactCallable.createNewContact($lastName, $firstName, $mail, $mailbox))
Class ExchangeContactCallable

2.15.10. Create and end Exchange email

Creates a new email for the current Exchange user.

Parameters:
$from - Sender address
$to - Recipient address
$subject - Subject text
$body - Message text

If additional properties are set or updated with set()-methods after creating the message, they have to be saved with $message.save() afterwards.

Example:
#set($message = $ExchangeMessageCallable.createNewDraft(strSender, strRecipient, strSubject, strBody))

$message.setCc("cc_recipient@example.org")
$message.save()
$message.send()
#set($message = $ExchangeMessageCallable.createNewDraft(strSender, strRecipient, strSubject, strBody))
Class ExchangeMessageCallable

2.15.11. Create an Exchange note

Creates a note for the current user.

Parameters:
$text - Text of the note
$mailbox - The user's mailbox that the note should be added to. If null, the current user's mailbox is used.

Example:
#set($note = $ExchangeNoteCallable.createNewNote("My note", null))
#set($note = ExchangeNoteCallable.createNewNote($text, $mailbox))
Class ExchangeNoteCallable

2.15.12. Create an Exchange task

Creates a task for the current user.

Parameters:
$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.

Example:
#set($task = $ExchangeTaskCallable.createNewTask(${cursor}dtStart, dtDue, "Task subject", null))

$task.setPercentComplete(25.0)
$task.save()
#set($task = $ExchangeTaskCallable.createNewTask(dtStart, dtDue, "Task subject", null))
Class ExchangeTaskCallable

2.16. If Else

Code snippet for an if else condition.
#if(condition1)
	##code for condition1
#elseif(condition2)
	##code for condition2
#else
	##code if no condition matches
#end

2.17. For each loop

foreach loop code snippet.
#foreach($element in )
	
#end

2.18. Define a variable

Example:
#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

Example:
#set($vhValue = $VH.getValueHolder(1))
#writeVH($vhValue, "currency", true, false, false)
#set($vhValue = $VH.getValueHolder($object))
#writeVH($vhValue, "<RENDERING_TYPE>", true, false, false)

2.20. Read request parameter

Read a request parameter.
$!Request.get("rq_param")
Class IServerBridgeRequest

2.21. Write request parameter

Write a request parameter.
$Request.put("rq_param", "strValue")
Class IServerBridgeRequest

2.22. All data groups of an application

Returns the names of all data groups of the application with the stated GUID.
#set($datagroups = $RtCache.getDataGroups($RtCache.filter.dataGroup.getByApplication(<Application GUID>)))
#foreach($datagroup in $datagroups)
	Name: $datagroup.getName()
#end
Class VelocityRtCache

2.23. Dynamic identification of a table name per sysident

To identify the table name via sysident, the expert attribute "sysident" has to be defined on the "Expert" tab of the data group properties. The sysident value is case-sensitive.
#set( $tablename = $AppWalker.getTableNameBySysident($Request.get("rq_AppGuid"), "MY_SYSIDENT"))
Class ApplicationWalker

2.24. Current date with the current user's time zone

Creates a current date considering the time zone of the current user.
$DtUtil.now($User.getTimeZone())
Class CalendarAwareDate

2.25. Create a JSON response

Creates a JSON response.
## This is necessary: Prevents the response from having line breaks, unwanted outputs, etc.
$Response.setIgnoreWrite(true)

## 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.
$map.put("myJSONAnswer", $myVar)

## This is necessary: Format the response so the server delivers JSON.
$Response.setHeader("Cache-Control", "no-cache")
$Response.setHeader("Content-Type", "application/json;charset=UTF-8")

## Format the map to be escaped for the JSON string.
$Response.setIgnoreWrite(false)$JSON.toJSONString($map)
Class JSONUtil

2.26. Create a GUID

Generates a new GUID.
$Unique.newGuid()
Class Unique