Failed to execute the [velocity] macro. Cause: [null]. Click on this message for details.
The database counter plugin may be installed as either a client plugin or a system plugin. It requries no additional configuration.

The database counter plugin lets you create one or more global counter in a database. The counter value may be incremented, decremented or reset during workflow processing. Some possible uses cases are:

  • A reservation form that counts the number of participants. When a certain limit is reached, further form submissions are blocked.
  • Generating a custom ID for a form record that is independent of the internal FORMCYCLE process ID. This is useful especially when the ID needs to conform to a certain pattern or has to be reset in regular intervals.
  • Repeating the actions of a certain state n times, where n is set depending of a submitted form value.

Furthermore, it is also possible to access the current value of the counter via a system variable during workflow processing; or via an AJAX request  from within a form.

Each counter has got both a name as well as a unqiue UUID. The UUID uniquely identifies a counter and is used when querying the counter value with an AJAX request.

Workflow action "Counter"

Once the plugin is installed, you can choose a new action in the workflow processing configuration. The action is a plugin action named Counter. You can use this action to modify the value of a counter or reset it in regular intervals.

Allgemeine Einstellungen

Failed to execute the [velocity] macro. Cause: [null]. Click on this message for details.
Base settings for the workflow action Counter. Here you can choose which counter should be changed and in what manner.
1 - Counter name
Name of the counter to be modified. For each counter you can see its name as well as its UUID. The UUID uniquely identifies a counter and is used when querying it via an AJAX request. To delete a counter, first select the counter, then click on the thrash icon to the right. To add a counter, first click on the plus icon, then enter a name for the new counter, and finally save the counter by pressing the floppy disc icon.
2 - Counting action
Lets you chose how the value of the counter should be changed. Possible options are:
Increment count
Adds the given amount to the current value of the counter.
Decrement count
Substracts the given amount from the current value of the counter.
Reset counter to start value
Sets the current value of the counter back to the selected initial value.
3 - Step size
Amount by which the counter is incremented or decremented.
4 - Initial value
The intial starting value of the counter. This is the value of the counter when it is first created. You may also reset the counter to this value.
5 - Reset automatically
When this option is enabled, the counter is reset automatically by the system when certain conditions are met; such as each week, or when the counter value reaches a certain limit. See below for how to configure this feature.

Reset automatically

Failed to execute the [velocity] macro. Cause: [null]. Click on this message for details.
Configuration for resetting a counter when its value exceed a given limit.
Failed to execute the [velocity] macro. Cause: [null]. Click on this message for details.
Configuration for resetting a counter on a daily basis.
Failed to execute the [velocity] macro. Cause: [null]. Click on this message for details.
Configuration for resetting a counter on a weekly basis.
Failed to execute the [velocity] macro. Cause: [null]. Click on this message for details.
Configuration for resetting a counter on a monthly basis.
Failed to execute the [velocity] macro. Cause: [null]. Click on this message for details.
Configuration for resetting a counter on a yearly basis.

When a counter is reset, then after the counter action was processed, its value will be equal to the configured initial value. For example: Assume the counter action was configured to increment the counter by 3 each time it is executed, and should be reset daily. Let the the current counter value be 39 and the intial value 11. The first counter action that is executed on a new day will now reset the counter to 11, and not be incremented at all. Starting with the second counter action of that day, the counter will be incremented by 3 each time the action is executed.

A counter may be reset either in regular intervals or when its value exceeds a certain threshold. This feature is available only if the checkbox reset automatically was enabled and the counting action was not set to Reset counter to start value.

Regarding resetting the counter in daily intervals: Please note that the counter is not reset by background task, but only when the workflow action counter is executed. Or, to be more precise, the counter value is reset (instead of being incremented or decremented), when the time points at which the counter should have been reset contains at least one point that lies between the last point in time the counter value was modified and the current point in time.

1 - Condition
Lets you choose when and how the counter should be reset.
Counter greater than or equal
Available only when the counting action was set to count up. The counter is reset to its initial value when, after the counter was incremented, its value is now greater than or equal to the limit entered in (2).
Counter less than or equal
Available only when the counting action was set to count down. The counter is reset to its initial value when, after the counter was decremented, its value is now less than or equal to the limit entered in (2).
daily
The counter is reset each day at the time of day as entered in (2).
weekly
The counter is reset at each of the days of the week selected in (2); at the time of day as entered in (2).
monthly
The counter is reset each month at the date and time of day as entered in (2) and (3).
yearly
The counter is reset each year the the day, month and time of day as entered in (2), (3), and (4), respectively.

General return parameters

Failed to execute the [velocity] macro. Cause: [null]. Click on this message for details.
Settings for the return parameters of the counter action. You can access the returned values via variables.

Sometimes it may be necessary to access the new value of the counter. To do so, you can use action variables for accessing the returned values of an action. The section general return parameters lets you configure the key you need to use for accessing the return values. For example, assume a counter action was named CountUp. Then you can use the variable [%$CountUp.RESULT[0].count%] to access the current counter value, provided you entered the key count in the input field (3). The following return values are available:

1 - ResultCode
A numerical value that indicates whether the counter action was successful or not. The following result codes are possible:
1 (OK)
The counter action was processed successfully.
10 (UNKNOWN_ACTION_ERROR)
The counter action could not be processed, an unknown counting action was selected. The currently supported counting actions are count up, count down and reset counter to start value.
11 (PARSING_ERROR)
A settings does not conform to the expected data type or syntax; such as when a letter was entered for the initial value (instead of a number).
40 (INTERNAL_ERROR)
The counter action was not successful. The type of error cannot be specified more closely.
2 - ResultMessage
An English description of the result (success or error).
3 - Counter
The new numerical value of the counter, after the counting action was applied.
4 - IsReset
Either true, when the counter was reset during the current action; or false if it was not reset.
5 - CounterAfterReset
In case the counter was reset: The numerical value of the counter before the reset.

System variable plugin

Failed to execute the [velocity] macro. Cause: [null]. Click on this message for details.
An example for how a counter value can be accessed via variables. Here we read the value of a counter that keeps track of the number of reservations for an event. When the user submits the reservation form, we check the current value of the counter against the limit for that event. When the limit is exceeded, we can return an appropriate error message to the users. Please note that this is meant as a server-side validation - to make the form user-friendly, you should indicate the number of free slots in the form itself.

Once the plugin is installed, you can access the current value of the plugin with a system variable. This can be used, for example, to access the counter value in the condition of a workflow action and compare it with a submitted value. The system variable has got the following pattern:

[%$DBCOUNTER.<CounterName>%]

So to access the value of a counter named test, you can use the following variable:

[%$DBCOUNTER.test%]

Counter servlet action plugin

Failed to execute the [velocity] macro. Cause: [null]. Click on this message for details.
An example for how the counter value can be accessed via an AJAX request. The URL is build with the metadata available in the form context. This avoids having to enter the URL directly in the code, which is error-prone: the host or context path could change, for example, when the form is moved between a development and production environment.

Once the plugin is installed, a new servlet plugin action is available that lets you access the current value of a counter via an HTTP request. This is useful, for example, to read the counter value from within a form and display it in the form. The URL for the counter action plugin servlet follows the following pattern:

https://<Host>/<FormcycleContextPath>/plugin?name=Servlet%20Counter&client-id=<ClientId>&id=<CounterUuid>

Assume FORMCYCLE was installed locally with the context path xima-formcycle. Let counter be used in a form of a client with the ID 1; and let the UUID of a counter be bc49d3b0-f869-4e59-864e-ddcc2925ed63. Then you can access that counter with the following URL:

https://localhost:8080/xima-formcycle/plugin?name=Servlet%20Counter&client-id=1&id=bc49d3b0-f869-4e59-864e-ddcc2925ed63

Alternatively, you may also specify the parameter project-id (ID of a form) instead of client-id. This ID is used only to determine which servlet action plugin should be run and is not used by the counter servlet action plugin itself:

https://<Host>/<FormcycleContextPath>/plugin?name=Servlet%20Counter&project-id=<FormId>&id=<CounterUuid>

Nach Ausführung des Servlet-Aktions-Plugin wird das Ergebnis als JSON-Objekt zurückgeliefert, siehe hierzu auch die Abbildung. Dieses JSON-Objekt hat die folgenden Einträge:

Status
Gibt an, ob der Servlet-Aufruf erfolgreich war. Der Wert ist ein weiteres JSON-Objekt mit folgenden Einträgen:
Msg
Ein nummerischer Wert, der angibt, ob der Servlet-Aufruf erfolgreich war. Mögliche Werte sind:
(OK)
(NO_REQUEST_ID_ERROR)
(NO_COUNTER_TO_UUID_ERROR)
Code
Eine englische Beschreibung des Resultats (Erfolg oder Fehler).
Counter
Informationen zum angefragten Zähler. Der Wert ist ein weiteres JSON-Objekt mit folgenden Einträgen:
Der aktuelle nummerische Wert des Zählers.
LastChange
Das Datum mit Uhrzeit, an dem der Zähler zuletzt geändert wurde. Das Datum wird mit dem Datums- und Zeitformat der aktuellen Server-Locale formattiert.
LastChangeTimestamp
Das Datum mit Uhrzeit, an dem der Zähler zuletzt geändert wurde. Der Zeitstempel ist eine ganze Zahl, welche die Anzahl an Millisekunden seit dem 1. Januar, 1970, 00:00:00 GMT angibt.
Value
Der aktuelle nummerische Wert des Zählers.
UUID
Die UUID des angefragten Zählers, dessen Wert ausgelesen wurde.
Name
Der Name des angefragten Zählers, dessen Wert ausgelesen wurde.
Tags:
Copyright 2000-2025