On-schedule Rules
An on-schedule rule defines a set of changes that are applied according to a set schedule. For example, you can periodically check for issues with specific attribute values and notify a user or a group. These rules replace the scheduled rules that were used in older workflows.
On-schedule rules are executed by a special workflow user. This is a system user account that is granted a full set of permissions. The permissions for this account cannot be modified. The workflow user account is not included in the license restrictions and is not displayed in the Users list.
Sample On-schedule Rule
This rule executes every day at 10:00. The rule checks for unresolved issues that are assigned and contain a value in the Due Date field. If the due date is in the past, a notification is sent to the assignee.
The components that define this on-schedule rule are as follows:
Again, the script starts with a
require
statement that references theentities
module in the workflow API. This means that everything that is contained in this module can be accessed in this script with theentities
variable.For this rule, the
exports.rule
property uses theIssue.onSchedule
method. This exports the script that follows the declaration as an on-schedule rule.The body of the rule itself contains definitions for the following properties:
Property | Description |
---|---|
title | An optional human-readable title. The title is only visible in the administrative interface. |
search | A 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 and Commands Attributes) 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, We strongly recommend that you make the search expression as concrete as possible, instead of adding conditions inside the action. |
cron | The schedule for applying the rule, specified as a Java cron expression. In this example, the expression triggers this rule every day at 10:00 in the time zone that is set for your YouTrack server. |
muteUpdateNotifications | A flag that determines whether update notifications are sent for changes applied by this rule. If you want to apply updates without sending notifications, set to When The value for this property does not affect notifications that are explicitly sent, as with the .notify method that is used in this example. This property is not relevant to this example, as the rule does not apply any issue changes. Even if it were set to |
modifyUpdatedProperties | A flag that determines whether the changes applied by this rule will update the value for the Available since 2023.1 |
guard | A 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. |
action | The 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. In this example, we use the |
requirements | The list of entities that are required for the rule to execute without errors. This property ensures that rules can be attached to projects safely. In this example, the requirements ensure that both the Assignee and Due Date fields store the correct types and are available in the project to which the rule is attached. If either field is absent, an error is shown in the Workflows list. The rule cannot be enabled until the required fields are attached. |