UI Event Actions

Prev Next

Such Actions are triggered when the user clicks the related Action Button on UI.

UIActions.png

There are different UI Event Actions available:

  • Create New Item in Another Module (Generic);

  • Create New in Another Module (Ordering);

  • Redirect to Custom URL.

There are UI Event specific settings available, like:

  • Label for Action Button — a text to be displayed on the button;

  • Action Button Position — where the button to be displayed: Action List or Toolbar.

Create New Item in Another Module (Generic)


The Action allows just to add a button which will open New Item window for the specified module. This is handy to use in pair with action which creates combinations based on the values of the source main item.

The only one specific parameter for this action is Target Module.

CreateInAnotherModule.png

Note: starting from v16, “Action button position” is no longer respected on New UI, and location is now defined by available space in the module search toolbar.

Create New in Another Module (Ordering)


This action allows to create items in another module like the previous one but uses additional specific logic and mappings to enable the Ordering functionality. See more about Ordering in the dedicated chapter.

OrderingAction1.png

OrderingAction2.png

Redirect to Custom URL


The Action can associate the button with a pre-defined URL. The user who clicks the Action button will be navigated to the URL specified. The typical usage can be for example connecting to a third-party system using the current item's data for generating the access token and providing it in GET request as a parameter for authentication.

RedirectURL.png

In the action settings, you can specify the URL using the Placeholders and Functions for fetching the data from the current item.

Placeholders

Use standard placeholders to insert the general data.

  • ${UserName} inserts the name of the current user.

  • ${UserEmail} inserts the email address of the current user.

  • ${SiteUrl} inserts the URL of the current site specified in Site Settings, e.g. https://qatest.com.

  • ${LoginUrl} inserts the Login Page URL, e.g. https://qatest.com/qa/common/login/ebms.

  • ${SiteId} inserts the ID of the current site.

  • ${ModuleId} inserts the ID of the current module.

  • ${ActionId} inserts the ID of the action.

  • ${CurrentItem} inserts Name Field value of the current item.

Example

You can pass the user's Name and Email as parameters:

https://localhost/loginPage?user=${UserName}&email=${UserEmail}

Functions and Variables

Use functions to fetch and format the data.

Syntax

Explanation

Returns

#set($variableName = 'sometext')

Define a variable that can be reused in the formulas. The variable can contain static text or result of the function

-

$CurrentItem

System variable which returns the current item object. It is possible to apply methods to this variable in order to get the specific data from the fields

-

$CurrentItem.fieldValue('field name')

Get a single value from the item field

String

$CurrentItem.fieldValue('module link').fieldValue('subfield')

Get a value from the module link sub-field

String

$CurrentItem.fieldValues('multiselect field name')

Get multiple values from the multiselect item field

Array of Strings

$tools.join(, 'delimiter', true/false)

Format multiple values with a delimiter, e.g. as a comma-separated list. Set true to skip the empty values. To get  use the previous formula

String

$tools.base64Encode('some string')

Encode the string to Base64 format

String

$date.get('yyyy-M-d H:m:s')

Inserts the action execution date by specified mask, e.g. 2018-3-19 21:54:51.

More about Formatting dates

String

$tools.aesGenerateKey('password', 'salt', , , 'algorithm')

Generate a key using the AES key generator. The key can be used for encrypting/decrypting the data that is passed as an access token and must be secure

String

$tools.aesEncrypt('value', 'key','init vector', 'cipher name')

Encrypt value using the key and init vector. Cipher name is optional

String

$tools.aesDecrypt('enctypted value', 'key', 'init vector', 'cipher name')

Decrypt value using the key and init vector. Cipher name is optional

String

$number.toNumber('#,###,###', $mnum))

Change output format of the Number ($mnum)

Number Patterns

 -

$date.format('MM/dd/yyyy', $mdate )

Change output format of the Date ($mdate)

Date Patterns

 -

For more formulas see Apache Velocity Engine documentation.

Single quote in field names must be escaped by an extra single quote:

$CurrentItem.fieldValue('Name with ''single  quote'' inside')

See more about How to escape the special characters.

Examples

Creating a UI Action which generates the secure access token and forms the redirect URL link to a third-party system.

  • Create the unique value for an access token by combining module link sub-field value (e.g.  number of the linked campaign) and current date

#set($valueForToken = $CurrentItem.fieldValue('Campaign').fieldValue('Number') + '_' + $date.get('yyyy-MM-dd'))
  • Generate an AES key for encrypting

#set($aesKey = $tools.aesGenerateKey('some_Password', '736f6d655f53616c54', 1024, 256, 'PBKDF2WithHmacSHA1'))
  • Specify the init vector variable

#set($initVector = 'fdbfdca92e0cd82e042a733626853d3f')
  • Encrypt the token using AES key and init vector

#set($encryptedToken = $tools.aesEncrypt($valueForToken, $aesKey, $initVector))
  • Generate a final link for a redirect, providing a token, user name and email

https://test.com/api/check/?token=$encryptedToken&name=${UserName}&email=${UserEmail}
  • Change output format of a Date from dd/mm/yyyy to mm/dd/yyyy

#set($mdate = $date.toDate('dd/MM/yyyy', '17/10/1991'))
$date.format('MM/dd/yyyy', $mdate )
// output 10/17/1991
  • Change output format of a value from Date-Time field

{
   "fieldDefinitionId": 4342,
   "name": "DateTime",
   "options": [
     {
        "id": 0,
        "value": "$date.format('MM/dd/yyyy HH:mm', $date.toDate('dd/MM/yyyy HH:mm', $CurrentItem.fieldValue('DateTime')))"
     }
   ]
 }
  • Change output format of a Number from 14,999,999.0 to 14999999

#set($mnum = $number.toNumber('#,###,###.###','14,999,999.0'))
$mnum //14999999
  • Change output format of a value from Number field

{
    "fieldDefinitionId": 4336,
    "name": "Int",
    "options": [
       {
         "id": 0,
         "value": "$number.toNumber('#,###,###', $CurrentItem.fieldValue('Int'))"
       }
   ]
 }
  • Convert number to specified format (US or International)

//convert number from International format to text field (result in International format):
$number.toNumber('###,###.00', $CurrentItem.fieldValue('Dec'), $danishLocale)

//convert number from International format to US format:
$number.format('###,###.00', $number.toNumber('###,###.00', $CurrentItem.fieldValue('Dec'), $danishLocale), $usLocale)

//convert number from US format to International format:
$number.format('###,###.00', $number.toNumber('###,###.00', $CurrentItem.fieldValue('DEC US'), $usLocale), $danishLocale)
  • Format decimal number that contains more then 7 digits

//If $CurrentItem.fieldValue('Dec') in International format = 22.999.778,05:
$number.format('#0.00', $number.toNumber('#,###,###.##', $CurrentItem.fieldValue('Dec'), $danishLocale))
//output: 22999778,05

//If $CurrentItem.fieldValue('Dec') in US format = 22,999,778.05:
$number.format('#0.00', $number.toNumber('#,###,###.##', $CurrentItem.fieldValue('Dec'), $usLocale))
//output: 22999778.05
  • To ignore Date/Number Fields by HTTP Action if empty:

#set($value = $CurrentItem.fieldValue('Week'))
#if( $value != "" )
#set($resultValue = $date.format('yyyy-ww', $date.toDate('ww-yyyy', $value)))
#else
#set($resultValue = "")
#end

{
	"active": true,
	"expired": false,
	"fields": [
{
			"fieldDefinitionId": 4343,
			"name": "Week",
			"options": [
				{
					"id": 0,
                                        "value": "$resultValue"
				}
			]
		}
	],
	"id": 0,
	"links": [
		{
			"href": "string",
			"rel": "string",
			"templated": true
		}
	]
}

Limitation: Somethimes Incorrect year inserts in Week-Year field that was formated from Text field by action.

For ex.: If user enters "2020-01" into text field he will see W1 2019 in "Week-Year" field instead of W1 2020