Skip to content

Roles

Roles define task responsibilities. Each role has the following configurable properties:

Name: The internal identifier for the role.

Caption: The user-visible name for the role. Supports localization.

Assignment Logic

Role assignment uses one of two methods: Decision Table or Expression.

Decision Table

A decision table defines assignment rules based on form data without requiring code. Rules are defined in the input section, and corresponding assignees are selected in the output section.

For details, see Decision Table.

Expression (Role Script)

A JavaScript script determines the assigned user(s).

Info

Role scripts must return at least one identity. An empty result or failure to return any identity will cause an error.

Advancing to Next Task

Selecting an action in role script by setting $WorkItem.SelectedAction advances the process to the next task without assigning the task to a user.

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.

Example Role Scripts

While a wizard simplifies common role definitions, the following examples demonstrate custom role scripts:

Assigning to a Specific Identity:

Replace 'd3b1fe89-6873-4438-8762-164ed73a9054' with the actual identity ID.

1
$Membership.Get('d3b1fe89-6873-4438-8762-164ed73a9054');

Assigning Based on Data Model Field:

Assuming an "Employee" field exists in the data model populated by a user form:

1
$Xml.Evaluate('Employee');

Assigning to Multiple Users:

Using a JavaScript array:

1
[$Xml.Evaluate('Employee'), $Membership.Get('d3b1fe89-6873-4438-8762-164ed73a9054')]

Alternatively, using semicolons:

1
$Xml.Evaluate('Employee') + ';' + 'd3b1fe89-6873-4438-8762-164ed73a9054'

Assigning to a Manager:

This script assigns the role to the manager of the user who completed the previous task:

1
$Membership.FindManager($WorkItem.Previous.CompletedBy);

Advance to Next Task

Automatically advance to the next task if approval is not required.

1
2
3
if (!$Xml.Evaluate('ApproveRequired')) {
    $WorkItem.SelectedAction = 'Approve';
}