YouTrack Standalone 2017.4 Help

Rule-specific Properties

All scripts that set a value for the exports.rule property are interpreted as workflow rules. Each type of rule supports a specific set of properties that define how the rule is executed.

Each module can only store a single object for the exports.rule property. When a script contains more than one definition for this property, the last definition in the script is exported. For example, if a script sets the exports.rule property to entities.Issue.onChange (the declaration for an on-change rule) then later sets this property to entities.Issue.action, the script is interpreted as an action rule. All of the properties that are set for the on-change rule are ignored.

This page lists all of the properties for each workflow rule by type. For examples that show you how these properties are used in actual rules, see Workflow Rules.

On-change Rule Properties

The Issue.onChange method exports an object that is interpreted as an on-change rule. On-change rules support the following properties:

PropertyDescription
titleAn optional human-readable title. The title is only visible in the administrative interface.
guardA function that determines the conditions for executing the rule. If the guard condition is not met, the action specified in the rule is not applied to an issue.
actionThe actions that should be applied to each issue. The action is declared as a function that accepts a context as an argument.
requirementsThe list of entities that are required for the rule to execute without errors. This property ensures that rules can be attached to projects safely.

On-schedule Rule Properties

The Issue.onSchedule method exports an object that is interpreted as an on-schedule rule. On-schedule rules support the following properties:

PropertyDescription
titleAn optional human-readable title. The title is only visible in the administrative interface.
searchA search query that determines which issues are processed by this rule. It can be a string that uses the syntax for a standard YouTrack search query (see Search Query Reference) or a function that recalculates a search string every time the rule is triggered. When you use a function, reference it by name. For example, search: getSearchExpression. We strongly recommend that you make the search expression as concrete as possible, instead of adding conditions inside the action.
cronThe schedule for applying the rule, specified as a Java cron expression.
guardA function that determines the conditions for executing the rule. If the guard condition is not met, the action specified in the rule is not applied to an issue.
actionThe actions that should be applied to each issue that matches the search condition. This action is triggered separately for each issue. The action itself is performed by the workflow user account.
requirementsThe list of entities that are required for the rule to execute without errors. This property ensures that rules can be attached to projects safely.

Action Rule Properties

The Issue.action method exports an object that is interpreted as an action rule. Action rules support the following properties:

PropertyDescription
titleA human-readable title. The title is used as the label for the command in the Apply Command dialog and the item in the Command Dialog list in the issue toolbar. If this property is not set, the command is not added to the menu.
commandThe text that is used for the custom command. When this command is applied to one or more issues, the actions that are defined in this rule are executed. Commands are defined server-wide, which means that you cannot have two action rules with the same command even when these rules are attached to different projects.
guardThe condition that determines when the action rule is enabled.

If the guard condition is not met, the custom command cannot be applied to an issue. The command is not suggested in the Apply Command dialog and its title is not visible in the issue toolbar.

actionThe changes that should be applied to each of the issues that are selected when the command is applied. This action is executed separately for each issue. The changes are made on behalf of the user who applies the command.
requirementsThe list of entities that are required for the rule to execute without errors. This property ensures that rules can be attached to projects safely.

State-machine Rules

The Issue.stateMachine method exports an object that is interpreted as a state-machine rule. State-machine rules support the following base properties:

PropertyDescription
titleAn optional human-readable title.
fieldNameThe name of the custom field that is managed by the state-machine.
statesThe list of field values and definitions for the transitions between them. Values that contain spaces and special characters are set in single quotes.
requirementsThe list of entities that are required for the rule to execute without errors. This property ensures that rules can be attached to projects safely.

For a state-machine rule, you do not need to add the field that is managed by the state-machine to the requirements. This field and its values are derived from the states property.

Each of the values that are defined in the states property contain definitions for the following additional properties:

PropertyDescription
initialA Boolean property that determines which of the values in the list is set when an issue is created. Exactly one value must set this property to true. For other values that are not set as the initial value, this property is optional and can be omitted.
onEnterAn optional function declaration that is called when the corresponding value is assigned to an issue. These functions behave similar to actions in other types of rules.
onExitAn optional function declaration that is called when the field value is changed from the current value to another value. These functions behave similar to actions in other types of rules.
transitionsThe list of possible target values that can be set for each value in the list.

For a state-machine rule, you do not need to list the values that are used by fields that are managed by the state-machine in the requirements. This field and its values are derived from the states property.

Each of the values that are defined in the transitions property contain a name property. The name is used to set this value in a command and is also shown in the list of values for a custom field. Each transition name contains definitions for the following additional properties:

PropertyDescription
targetStateThe actual name of the value that is set when the command specified in the name property is applied.
afterAn optional property that sets an interval for performing an action. The action itself is specified in the action property.
actionAn optional property for any transition that behaves similar to actions in other types of rules..
guardAn optional condition that determines when the transition is allowed. If the guard condition is not met, the value for the custom field cannot change to the value that is defined for this transition.
Last modified: 12 December 2017