Skip to Content

Understanding and changing context in CMW Tracker

The concept of context is used in CMW Tracker to set up business logic and computation. First of all, any information system has a database, and to get some data from it, you need to write a query to the database.

Context is the starting point for a database query. Context boundaries are the applications, tasks, triggers, etc., in which the query is written (in the form of computed attributes, conditions for transitions, filters, and so on), and must be distinguished to write the formula correctly.

$ is the initial context designation.

  • For calculated attributes, $ is the context of the current application.
  • For prefilters of referenced fields, $ is the context of the application referenced by this field.
  • For tasks, $ is the task context.
  • For a trigger, $ is the context of the application defined in the previous activity (initially this is the context of the current application).

$$ are system variables that do not depend on the context of any particular application:

  • currentUser = current user;
  • contextItem = original object;
  • now = current date and time;
  • incomingMessage = current message (for a trigger to receive an email message);
  • contextComment = current comment (for a trigger to add a comment).

Generally, reference fields are used to change the context. To do so, use the system names of the attribute of "Reference" type after $ and symbols -> or <- (for a back reference) after the system name. In triggers, you can change the context using the attributes of the "Reference" type or without attributes, simply by changing the context to another application.

 

Context change examples

Example 1: the attribute you are looking for is in another application, and there is a link to this application in the current context (for example, to calculate some field)

$fieldReference->fieldText

Example 2: the required attribute is in another application that refers to the current one, while there is no reference to this application in the current context (for example, to calculate a field)

$<-fieldReference->fieldText

Example 3: you are in the context of a task, and the desired attribute is in the context of a related record (for example, to calculate the Assignee)

$parent->field

Note : in case of subtasks, $parent will change the context to the parent subtask or parent task. Keep this in mind when writing expressions.

Example 4: within the trigger, you changed the context several times from application to application, and at the end you need to fill the field with the value from the original object that started the trigger

$$contextItem->field