Skip to content

Automation Module

The Automation Module executes scripts within a process, enabling operations such as database or data model updates. Scripts typically conclude by assigning a value to the $WorkItem.SelectedAction property to indicate the task's status.

Example Automation Script

The following JavaScript example demonstrates an automation script:

1
2
3
4
5
6
$Xml.SetValue('CustomerCount', $Xml.EvaluateNumber('CustomerCount') + 1);
if ($Xml.EvaluateNumber('CustomerCount') < 10) {
    $WorkItem.SelectedAction = 'Continue';
} else {
    $WorkItem.SelectedAction = 'Completed';
}

Scripting Objects

This script is executed in the backend context of the Emakin and does not have an accessible a browser DOM context and therefore navigator based JavaScript libraries such as jQuery are not available.

The following objects are available:

  • $WorkItem Current WorkItem that is being processed.
  • $Instance Instance of the Instance current workflow instance.
  • $TestMode Indicates whether the workflow is running in test mode. In test mode, evaluates to true value.
  • $Priority Priority of the current workflow instance 0 (lowest) to 5 (highest
  • $Initiator Identifies the workflow initiator. Note that this may be null for module-type tasks.
  • $Culture Current culture of the workflow instance. Originated from the initiator's culture but can be overridden. Culture is specified in the format languagecode2-country/regioncode2. Example: (en-US or tr-TR)
  • $Templates Provides access to templates defined in the pool definition. Used for rendering the text content depending on the culture of the workflow instance.
  • $Xml Provides access to the process data model or workflow data.
  • $Case Instance of Case instance if workflow started on a case.
  • $poolVariable Custom defined pool variable by name. Variables are defined in Variables
  • $Services Allows calling SOAP services with JSON or XML content types.
  • $Decisions Allowing you to execute decision tables and models on process.
  • $scriptModule Custom defined script module. Script modules are defined in Script Modules
  • $Domain Provides access to the domain information and related methods like initiating a workflow or creating a new case.
  • $ActivityStream Allows pushing system-generated activities to the domain activity stream.
  • $Membership Provides access to users and organizational database objects.
  • $Database Allows you to perform relational database operations.
  • $Crypto Provides access to cryptographic functions such as hashing and encryption.
  • $Rest Allows interaction with REST services using JSON or XML content types.
  • $Calendar Provides access to calendar functions like adding or subtracting date in calendar rules.
  • $Files Allows access to the standard file repository for basic files.
  • $Documents Provides access to the document archive.
  • $Delegation Pprovides methods to manage delegations between users.
  • $Messages Provides functionality for sending new e-mails and parsing existing e-mail messages.
  • $XmlRepository Provides access to the non-relational XML repository database.

Initiating Workflow Instances

Automation Module tasks can serve as starting points for automated workflow initiation using the following methods:

Scheduled Evaluation: Configure a scheduled evaluation to initiate workflow instances periodically. If the module script does not explicitly set $WorkItem.SelectedAction, the workflow instance will revert. Ensure the script takes action to manage the workflow's progression.

Scripting Initiation: Utilize the WorkItem.Initiate method to initiate other processes programmatically.

Join State and Continuation

If an Automation Module task is not designated as a starting point and the script does not set $WorkItem.SelectedAction, the workflow transitions to a "join state," pausing the workflow instance indefinitely at the automation task. Continuation can be achieved via:

Deadline: Assigning a deadline to the task will automatically trigger a deadline action, continuing the workflow at the specified time.

Scheduled Evaluation: A configured evaluation schedule can periodically assess conditions and determine whether to continue the workflow.

Programmatic Continuation: The WorkItem.ProcessWorkItem method can be called from other workflow instances to forcibly resume the paused instance.