Send Email on Batch Operations Actions

Prev Next

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

SendEmailBulk.png

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

#set($variableName = 'sometext')

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

-

$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

Bulk Functions

Syntax

Explanation

Returns

$tools.fetchAll()

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 foreach syntax explained below

Array of Objects

$tools.fetchFirst()

Get the first item object in a batch

Object

$tools.fetchUnique('field name') 
$tools.fetchUnique('field name', 'subfield name')

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

$variable_with_item.fieldValue('field name')

Get a single value from the item field

String

$variable_with_item.fieldValue('module link').fieldValue('subfield')
$variable_with_item.fieldValue('user field').fieldValue('name')

Get a value from the module link sub-field. This also works for User field (supported values: 'name', 'login', 'email', 'mobile_email', 'mobile')

String

$variable_with_item.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 items with empty values.  is an array of strings

String

#foreach($currentItem in ) 
   $currentItem. 
#end

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

$tools.report(templateId, 'filterValue', 'customName')

Generate a link to download the report with processed items.

  • templateId — ID of the item with a template in Report module.

  • filterValue — a value to filter the report data. The filtering field has to be preconfigured in the report template.

  • customName — the name of the report file.

See about Reporting Tool.

String

$tools.base64Encode('some string')

Encode the string to Base64 format

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 must be secure (e.g. access token). See the usage example

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

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