Requirements
The requirements object serves two purposes.
First, it functions as a safety net. It specifies the set of entities that must exist for a rule to work as expected. Whenever one or more rule requirements are not met, corresponding errors are shown in the workflow administration UI. The rule is not executed until all the problems are fixed.
Second, it functions as a reference. Each entity in the requirements is plugged into the
contextobject, so you can reference entities from inside your context-dependent functions (like anactionfunction).
There are two types of requirements: project-wide and system-wide.
Project-wide requirements contain a list of custom fields to be attached to each project which uses the rule as well as the required values from the sets of values for each custom field.
System-wide requirements contain a list of other entities that must be available in YouTrack. This includes users, groups, projects, issues, tags, saved searches, and issue link types.
Common Usage
Use requirements to describe the entities that your rule expects to find, then use the requirement aliases in the rule body. If the project that uses the rule does not have a matching field, value, or entity, YouTrack reports the problem in the workflow administration UI before the rule runs.
The following on-change rule requires a Priority field with the Major and Normal values, and a user with the qa.lead login. When an issue becomes unresolved, the rule changes the issue priority to Major and assigns the issue to the required user.
In this example, Priority, Assignee, and QALead are aliases. For the Priority and Assignee fields, the aliases match the actual field names, so the name property is omitted. The Major and Normal aliases represent required values in the Priority field. In the action, ctx.Priority.Major references the required Major value, and ctx.QALead references the required user.
Example
Here's an example of a requirements statement that includes the definitions for a custom field and the values that are required for this field, followed by a list of system-wide requirements.
Properties
Every entity that is specified in the requirements statement is identified by an alias. In the example above, the Priority field is assigned the alias P. When you assign an alias to an entity in the requirements, you use the alias to reference the entity in context. For example, the Priority field can be referenced as ctx.P, issue.fields.P, or issue.fields.Priority.
Each requirement that is specified in the requirements statement has the following properties:
Property | Description | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
type | The data type of the entity. This property is required. Here is the complete list of types for custom fields:
The following types are used for system-wide entities:
Project teams are represented as user groups. To specify a project team in requirements, use | ||||||||||||||||||||||||||||||||||||||||||
name | The name of the entity. This property is optional. If a name is not set, it is considered to be equal to the alias. For specific system-wide entities, this property is ignored entirely.
|
In addition, there are properties that are only available for specific entity types. These properties are listed below:
Entity | Property | Description |
|---|---|---|
custom fields | value | Any property that is defined for an entity that is not one of the known properties listed above is considered to be the requirement for a value in the set of values for a custom field. Each In the example above, the value |
multi | A Boolean property. When | |
issue links | outward | The outward name of the issue link type. |
inward | The inward name of the issue link type. | |
users | login | The login for a specific user. Used instead of the |
issues | id | The ID of a specific issue. Used instead of the |