Batch Actions are triggered on the operations with multiple items and provide the ability to Send Email with aggregated data from the processed items.
The events handled:
Event | Explanation |
Batch File Upload | Creating items on Bulk Upload operation |
Batch Combinations | Creating items by Execute Task Action "Create/Update items in another module" with combination option enabled |
Batch Field Import | Creating/Updating multiple items via the Import mechanism |
Batch Workflow | Updating items' status via Bulk Status Change operation |
The items' data can be fetched and formatted using the syntax of Apache Velocity Engine. Also, standard placeholders can be used for inserting the general data.
Placeholders
Use standard placeholders to insert the data.
${BatchId}
inserts the identifier of the processed items batch.${BatchType}
inserts the type of the batch: Upload, Combination, Import, Workflow.${TotalItems}
inserts the total number of processed items.${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.
Functions
Functions of Apache Velocity Engine allow to fetch and process the data from items.
The keyword #set
is used for defining a variable. The system variable $tools
is normally used for fetching data and calling functions. $date
is a system variable for working with dates. Functions also can be called for the user-defined variables.
Basic Functions
Syntax | Explanation | Returns |
| Define a variable that can be reused in the formulas. The variable can contain static text or result of the function | - |
| Encode the string to Base64 format | String |
| Inserts the action execution date by specified mask, e.g. 2018-3-19 21:54:51. More about Formatting dates | String |
Bulk Functions
Syntax | Explanation | Returns |
| Get a list of all item objects in a batch. Note, this function returns the objects array, not the text data. To process them use | Array of Objects |
| Get the first item object in a batch | Object |
| Get all unique values in a batch of items by a specific field. If 'field name' is a module link, use additional 'subfield name' parameter to define a field in linked module | Array of Strings |
| Get a single value from the item field | String |
| Get a value from the module link sub-field. This also works for User field (supported values: 'name', 'login', 'email', 'mobile_email', 'mobile') | String |
| Get multiple values from the multiselect item field | Array of Strings |
| Format multiple values with a delimiter, e.g. as a comma-separated list. Set true to skip the items with empty values. is an array of strings | String |
| Iterate through the list of items and process them one by one in cycle. Please, note! "CurrentItem" (capital C) is working only for single operation actions. For batch operations, use $currentItem (lowercase c) as in provided help text in action configuration. | - |
Special Functions
Syntax | Explanation | Returns |
| Generate a link to download the report with processed items.
See about Reporting Tool. | String |
| Encode the string to Base64 format | String |
| Generate a key using the AES key generator. The key can be used for encrypting/decrypting the data that must be secure (e.g. access token). See the usage example | String |
| Encrypt value using the key and init vector. Cipher name is optional | String |
| Decrypt value using the key and init vector. Cipher name is optional | String |
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
Generate a link to batch item list in Spreadsheet View using the predefined variable and standard bulk operation placeholders. Note, the path is encoded to Base64 format:
#set($targetPathGrid = "/site/${SiteId}/home#/module/${ModuleId}/view/list?batchId=${BatchId}")
${LoginUrl}?targetPath=$tools.base64Encode($targetPathGrid)
Generate a link to batch item list in Gallery View:
#set($targetPathGallery = "/site/${SiteId}/home#/module/${ModuleId}/view/gallery?batchId=${BatchId}")
${LoginUrl}?targetPath=$tools.base64Encode($targetPathGallery)
Generate a link to report file. The report will contain only the items from a specific campaign:
#set($customFilter = "$tools.fetchFirst().fieldValue('Campaign')")
#set($customName = "Report_$date.get('yyyy-M-d H:m:s')")
${SiteUrl}/$tools.report(26, $customFilter, $customName)
To be able to specify a filter set the key placeholder
{filterValue}
as a filtering value in the Report Template filtering settings:
Field
Filter
Value
Campaign
Contains
{filterValue}
See more about Reporting Tool.
Get the comma-separated list of unique emails from the items in a batch:
#set($emails = $tools.fetchUnique('User Link field', 'Email'))
$tools.join($emails, ',', true)
Iterate through the batch items and get a value of 'Created By' field for each item:
#foreach($currentItem in $tools.fetchAll())
$currentItem.fieldValue('Created By')
#end
Get the email for user field of the first item in a batch. Supported values: 'name', 'login', 'email', 'mobile_email', 'mobile':
$tools.fetchFirst().fieldValue('user field').fieldValue('email')
Get the value from the specified field in the linked module:
$tools.fetchFirst().fieldValue('module link field').fieldValue('field in linked module')
Get the pair 'Name - Email' for each user in multiselect User link field for every item in a batch. Note, the nested
foreach
cycles are used for that:
#set($allItems = $tools.fetchAll())
#foreach($currentItem in $allItems)
#set($valuesInMultiUserField = $currentItem.fieldValues('MultiUserField'))
#foreach($value in $valuesInMultiUserField)
$value.fieldValue('Name') - $value.fieldValue('Email')
#end
#end