Introduction
What are Hash Variables?
Hash variables in Joget are placeholders used to dynamically display data within applications. They allow users to insert dynamic content without hardcoding values, which enhances flexibility and customization. Hash variables can fetch and display data from various sources such as forms, workflows, and the system itself. They promote customization and flexibility by avoiding hardcoded values, ultimately improving the user-friendliness of Joget applications.
- Form Builder
- List Builder
- UI Builder
- BeanShell code
- Supported plugin configuration properties
- Activity name in Workflow Designer
- External Form URL when mapping an activity to an external form
to return the value of some useful runtime variables from Joget components. Download the hash variable demonstration app for a quick look.
Nested Hash Variable
A Hash Variable can be used inside another Hash Variable to form a Nested Hash Variable.
The syntax for the inner Hash Variable is wrapped by a pair of {curly bracket}.
#prefix.{prefix.variableKey}#
#date.{envVariable.dateFormat}# #user.{variable.username}.firstName# #form.tableChild.field1[{form.tableParent.childId}]#
Form Hash Variable by Index
You can pass an index or primary key value to a Hash Variable for retrieval.
The syntax for the inner Hash Variable is wrapped by a pair of [square brackets] .
#form.myTable.fieldId.[primaryKeyValue]#
Here are some examples:
#form.contact.name[007]# where "007" is the primary key or "id" value of database table "app_fd_contact".
Escaping the Resultant Hash Variable
The parsed/returned Hash Variable may cause incompatibility with the current context/environment such as syntax error in a script. Therefore, one may pass in additional parameters into the hash variable declared to escape certain characters. Before ending a hash variable with a hash "#", add a question mark character "?" followed by the required format, for example "#form.table.photo?img2base64#". You may include multiple by defining semicolon ";" separated values.
- regex - Used to escape regular expression special characters
- json - Used to escape JSON special characters
- javascript - Used to escape Javascript special characters
- html - Used to escape HTML special characters
- xml - Used to escape XML special characters
- java - Used to escape Java special characters
- sql - Used to escape SQL special characters
- url - Used to escape URL special characters
- nl2br - Used to convert new line character to <br> HTML tag
- separator(SEPARATOR_CHARS) - Used to change the default separator ";" to the SEPARATOR_CHARS. eg. ?separator(, ) resulted "abc, def" instead of "abc;def".
- img2base64 - hash variable escape method to convert image tag src in a Rich Text Editor to base64 data string which can be displayed in email (however Gmail does not support Base64).
- expression - Used to escape String characters in nested hash variable that may otherwise conflict with syntax/symbols used in the Expression Hash Variable
- noescape - Used to escape SQL query strings in JDBC binders to prevent the "<>" "not equal" operator from being converted, i.e. disables XSS prevention checking. (Available from Joget DX 7.0.7 and higher.)
Note: The following escape formats will not be checked for XSS prevention: "regex, json, javascript, html, xml, java, sql, url, expression, noescape".
#envVariable.script?java# #envVariable.script?nl2br;json# #form.table.users?separator(, )#
Hash Variable Return Values
- If the record does not exist, "#form.table.field#" returns the same = "#form.table.field#". Use the ternary operator ( condition ? exprIfTrue : exprIfFalse ) to check and set to NULL if the return value matches the origin hash variable (if used in BeanShell or Javascript).
- If record exist but field is empty, "#form.table.field#" returns empty = "".
- If record exist and field has value "abc", "#form.table.field#" returns the value = "abc".
Hash Variable Features In Joget DX Community Edition
Some hash variables listed below are not available in the Joget Community Edition, read the Detailed Plugin Comparison Between Editions for more information.
Hash Variable - Property Assistant
This is a new feature in Joget DX 8.
Property Assistant is a new feature in Joget DX 8, that allows you to quickly access and insert Hash Variables (and others) in any form element, UI element or list.
The Property Assistant allows you to choose a hash variable's attributes from a select box (Figure 1).
Figure 1: Property Assistant - Hash Variable Attributes Selection
You can also insert Nested Hash Variables easily using the Property Assistant by clicking on the desired attribute that will include the nested variable and then clicking back on the variable list to choose a variable to insert. (See Figure 2)
Figure 2: Property Assistant - Nested Hash Variable
System-wide Hash Variable
This is a new feature in Joget DX 8.2.
The System Variables menu introduces system-wide Hash Variables, which allows users to create and define custom hash variables that can be used in Property Assistant. This means that system-wide hash variables can be used in any app as it is not tied to any specific app.
System-wide Hash Variables can be accessed in Property Assistant using the #sysVariable.KEY# hash variable, where KEY is defined in the System Variables settings page.
List Of Joget DX Hash Variables
Workflow Assignment Hash Variable
Name | Description |
---|---|
Prefix | assignment |
Description | To get workflow activity information of the current assignment. |
Attributes |
|
Scope of Use |
|
Sample Attributes | To display the assignee's name: #user.{assignment.assigneeId}.firstName# #user.{assignment.assigneeId}.lastName# |
Workflow Process Hash Variable
A new #process.recordId# hash variable was introduced in Joget DX to retrieve the process database table id (or primary key value) which will return the UUID id value of the process record stored in app_fd_[form_table_name], if the General Settings > Run Process Primary Key is set to "UUID". If the "Run Process Primary Key" option in General Settings is set to "Process instance ID", the "#process.recordId#" will return the same value as "#process.processId#".
Read related documentation:
Name | Description |
---|---|
Prefix | process |
Description | To retrieve information of a workflow process instance. |
Attributes |
|
Scope of Use |
|
Sample Attributes | To display the performer username of an activity instance of a process instance: #process.activityInst.assign.performerUser[{assignment.processId}]# |
Current User Hash Variable
Name | Description |
---|---|
Prefix | currentUser |
Description | To retrieve currently logged in user information. More user hash variables here. |
Attributes |
In Joget Enterprise edition, these additional attributes are available:- User Meta
Employment
HOD
Organization
Department
Department HOD
Grade
Group
|
Scope of Use |
|
Date Hash Variable
Name | Description |
---|---|
Prefix | date |
Description | To get date time according to a specified format. Localization The returned value would follow current logged in user's timezone. If user's information is not available, then it will use server's timezone. |
Attributes |
Options dateFormat
dateUnit
integerValue
INPUT_DATE_VALUE accepts any date value and even nested hash variables, e.g: form data hash variable. See example in sample attributes below. INPUT_VALUE_FORMAT is the INPUT_DATE_VALUE original format. DATE_FORMAT_TO defines the format to change to. The above date hash with format control will use the login user's time zone setting and automatically adjust the date and time. If the user's time zone setting is blank, it wil revert to the System Settings "System Time Zone" property. If you want to perform a date formatting without using the time zone value, download and import the Date Formatter Hash Variable plugin from Joget Marketplace. New Feature use "#dateEN.dateFormat" to force the date to be displayed in English. This is a new feature in DX 8. |
Scope of Use |
|
Sample Attributes | #date.h:mm a# // shows current time of 12:08 PM #dateEN.yyyy-MM-dd# // shows current date of 2023-02-15 in English even though the locale has been set to a different language. (i.e Arabic) #date.EEE,d MMM yyyy h:mm:ss a# // shows current date time of Wed, 4 Jul 2014 12:08:56 PM #date.DAY+7.EEE,d MMM yyyy h:mm:ss a# // Add 7 days on top of current date time - Wed, 11 Jul 2014 12:08:56 PM #date.DAY-1.EEE,d MMM yyyy h:mm:ss a# // Minus 1 days on top of current date time - Wed, 3 Jul 2014 12:08:56 PM #date.dd-MM-yyyy[{form.j_expense_claim.title}|yyyy-MM-dd]# // Retrieves date from j_expense_claim table, form field title, changes its origin format of yyyy-MM-dd to dd-MM-yyyy. |
Environment Variable Hash Variable
Name | Description |
---|---|
Prefix | envVariable |
Description | To retrieve Environment Variable values. |
Attributes |
|
Scope of Use |
|
Sample Attributes | #envVariable.smtpServer# #envVariable.smtpPort# |
App Variable Hash Variable
This is a new feature in Joget DX.
The App Variable Hash Variable has the same functionality as the Environment Variable Hash Variable. Both can be used to retrieve App/Environment variable values in Joget DX 8
Name | Description |
---|---|
Prefix | appVariable |
Description | To retrieve App Variable values. |
Attributes |
|
Scope of Use |
|
Sample Attributes | #appVariable.smtpServer# #appVariable.smtpPort# |
Form Data Hash Variable
Name | Description |
---|---|
Prefix | form |
Description | To get field value from form table. |
Attributes |
|
Scope of Use |
|
Sample Attributes | #form.registration.registeredDate# //will use the current record ID #form.registration.registeredDate[ 0001 ]# //0001 is the record ID to seek for #form.registration.registeredDate[{variable.recordId}]# //using nested Hash Variable with curly bracket. |
Form Binder Hash Variable
Name | Description |
---|---|
Prefix | binder |
Description | To get field value or field value label from the binder of a form via its form definition id . The 'binder' prefix retrieves the field value, while the 'binder.options' prefix retrieves the lookup field (eg. select box, checkbox & radio button) option label. The field value or field value label can also be obtained from other apps by including the APP_ID, else it uses the current app context. By providing the PRIMARY_KEY argument, field value or field value label from a different record can be retrieved, else data from the current record id is retrieved instead. |
Attributes |
|
Scope of Use |
|
Sample Attributes | #binder.addCard.title# #binder.cardViewer.addCard.title# #binder.cardViewer.addCard.title[b30bce20-c0a82095-14976e70-fded1735]# #binder.options.addCard.title# #binder.options.cardViewer.addCard.title# #binder.options.cardViewer.addCard.title[b30bce20-c0a82095-14976e70-fded1735]# |
App Definition Hash Variable
Name | Description |
---|---|
Prefix | appDef |
Description | To retrieve App Definition information |
Attributes |
|
Scope of Use |
|
Sample Attributes | To display the app definition name: #appDef.name# |
App Translation Hash Variable (Internationalization)
Name | Description |
---|---|
Prefix | i18n |
Description | To support language localization on application level. |
Attributes |
|
Scope of Use |
|
Sample Attributes | #i18n.logout# |
Example | Please see Add Translation. |
Performer Hash Variable
Name | Description |
---|---|
Prefix | performer |
Description | To get user information of the performer of an activity. |
Attributes |
|
Scope of Use |
To get activityDefId (activity definition ID), mouseover the activity name in the Activity Mapping tab (Workflow Management Console); there will be an overlay showing the ID. The activity chosen must had already been performed. |
Sample Attributes |
|
Request Parameter Hash Variable
Name | Description |
---|---|
Prefix | requestParam |
Description | To access request parameter' values. |
Attributes |
|
Scope of Use |
|
Sample Attributes |
|
User Hash Variable
Name | Description |
---|---|
Prefix | user |
Description | To get user information based on username. Replace the username below in red with the actual username (example admin) or {currentUser.username}. |
Attributes |
In Joget Enterprise edition, these additional attributes are available:- User Meta
Organization
Department
Grade
HOD
Group
Employment
Department HOD
|
Scope of Use |
|
Sample Attributes |
|
Userview Key Hash Variable
Name | Description |
---|---|
Prefix | userviewKey |
Description | Userview Key Hash Variable is used solely for the purpose of accessing the current UI key's value. Typical use case for this hash variable are:-
|
Attributes |
|
Scope of Use |
Workflow Variable Hash Variable
Name | Description |
---|---|
Prefix | variable |
Description | To get the value of a workflow variable in a Process Flow. |
Attributes |
|
Scope of Use |
|
Sample Attributes | #variable.approvalStatus# |
Request Hash Variable
Name | Description |
---|---|
Prefix | request |
Description | To get the value from the current HttpServletRequest object of the page view. |
Attributes |
|
Scope of Use |
|
Sample Attributes | To retrieve the "Referer" header attribute value in the screenshot above, one may use the following hash variable. Hash Variable #request.header.Referer# See following example of retrieving a Joget APP URL using the Request Hash Variable. Request Hash Variable for an App's URL #request.scheme#://#request.serverName#:#request.serverPort##request.contextPath#/web... |
Platform Hash Variable
Name | Description |
---|---|
Prefix | platform |
Description | To retrieve platform specific information. |
Attributes |
|
Attributes For SMTP |
|
Additional attributes for Joget Enterprise & Professional editions |
|
Scope of Use |
|
Users Hash Variable
Name | Description |
---|---|
Prefix | users |
Description | To retrieve information of all the users in the selected group, grade, department and organization. Multiple results will be separated by semicolon. |
Attributes |
|
Scope of Use |
|
Sample Attributes | To return all the users in the current user's groups id:
|
Bean Shell Hash Variable
Name | Description |
---|---|
Prefix | beanshell |
Description | Using App Variable to execute bean shell script. Passing parameter using URL query string syntax. |
Attributes |
|
Scope of Use |
|
Sample Attributes | To execute a script stored in the "welcome" app variable with parameter "username" and "dept": if (username != null && username.length == 1 && !username[0].isEmpty()) { return "Welcome " + username[0] + " (" + dept[0] + "),"; } else { return ""; }
|
Related Tutorials |
Datalist Hash Variable
The "datalist.col" (highlighted in Bold in the table below) Hash Variables are a new feature in DX 8 that allows users to access and display a List's column data in multiple formats.
Name | Description |
---|---|
Prefix | datalist |
Description | To display the List records in a grid format in your form or email tool. |
Attributes |
|
Scope of Use |
|
Sample Attributes |
|
** for "datalist.col.xx.ID.column" variables, the "column" parameter refers to the order of the column in the list starting from 0. hence, to refer to the first column in a list called list_f1, your hash variable would look like this : #datalist.col.sum.list_f1.column_0
** the column are counted from 0, and does not include the default checkbox included in list tables
Expression Hash Variable
Name | Description |
---|---|
Prefix | exp |
Description | Mathematical and string operations on hash variables |
Attributes | #exp.variable# |
Scope of Use |
|
Sample Attributes | Testing Values
Mathematical operators
Logical operators
Relational operators
Ternary Operator (If Else)
String methods Note: Basically most of the String methods can be used, using `?expression` to escape single quote in value.
Custom Methods
Math methods Note: All java.lang.Math methods can be used.
|
Report Builder Hash Variable
The API IP/Domain Whitelist setting in General Settings needs to be configured in order for reportLink hash variable to work. If a request is from a non-whitelisted IP/domain, the response will be a HTTP 400 Bad Request.
Name | Description |
---|---|
Prefix | reportLink |
Description | To retrieve the particular report based on the reportId. To know more about Report Builder, see here. |
Attributes |
|
Scope of Use |
|
Sample Attributes |
|
Code Builder Hash Variable
Name | Description |
---|---|
Prefix | code |
Description | To retrieve the template based on the code snippet ID. |
Attributes |
|
Scope of Use |
|
Sample Attributes |
|
uiListCount Hash Variable
This is a new feature in Joget DX 8.
Name | Description |
---|---|
Prefix | uiListCount |
Description | The uiListCount hash variable is primarily utilized to retrieve the Datalist or Inbox menu count value. |
Attributes |
|
Scope of Use |
uiListCount cannot be used inside UI permission. This is due to: ERROR 15 May 2024 09:27:20 org.apache.jsp.WEB_002dINF.jsp.error500_jsp - Handler dispatch failed; nested exception is java.lang.StackOverflowError2org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.StackOverflowError |
Sample Attributes | See examples below, based on the usage within the default CRM application:
|
Escape Format Hash Variable
This is a new feature in Joget DX 8.
Name | Description |
---|---|
Prefix | ?decimal(decimal_number) |
Description | The escape format hash variable used to allow the formatting of decimal places. This hash variable can be use on any variable that have decimal values. |
Attributes |
|
Scope of Use |
|
Sample Attributes |
|
Stats Hash Variable
Name | Description |
---|---|
Prefix | stats |
Description | Display various Joget system and app statistics. |
Attributes |
|
Scope of Use |
|
Sample Attributes |
|