YouTrack Standalone 2021.1 Help

SLA Priority

This workflow automatically updates the priority of an issue if it is not resolved within a set time frame.

Name@jetbrains/youtrack-workflow-auto-raise-priority
Previous TitleAuto Raise Priority
Auto-attachedno
ModulesRaise priority from "Normal" to "Major" if not resolved in 7 days (on-schedule rule)
Raise priority from "Major" to "Critical" if not resolved in 10 days (on-schedule rule)
Raise priority from "Critical" to "Show-stopper" if not resolved in 12 days (on-schedule rule)
date-utils (custom script)

Use Case

This workflow helps you meet specific service-level agreements. The default workflow is set up for a support desk that tries to resolve all issues within 14 days. As this deadline approaches, unresolved issues automatically increase in priority.

Modules

This workflow includes three rules that change the priority based on the amount of time that has passed since an issue was opened. You can easily customize this workflow to help you resolve issues within a set time frame by simply changing the number of days.

Raise priority from "Normal" to "Major" if not resolved in 7 days

The first module contains an on-schedule rule that changes the priority of an issue from Normal to Major if it is not resolved after seven days. The rule runs daily starting at 08:00.

const entities = require('@jetbrains/youtrack-scripting-api/entities'); const days = require("./date-utils").days; exports.rule = entities.Issue.onSchedule({ title: 'Raise priority from "Normal" to "Major" if not resolved in 7 days', search: '#Unresolved priority:Normal', cron: '0 0 8 1/1 * ? *', guard: (ctx) => { return ctx.issue.created < Date.now() - days(7); }, action: (ctx) => { ctx.issue.fields.Priority = ctx.Priority.Major; }, requirements: { Priority: { type: entities.EnumField.fieldType, Normal: {}, Major: {} } } });

Raise priority from "Major" to "Critical" if not resolved in 10 days

The second module contains an on-schedule rule that changes the priority of an issue from Major to Critical if it is not resolved after ten days. The rule runs daily starting at 08:05.

const entities = require('@jetbrains/youtrack-scripting-api/entities'); const days = require("./date-utils").days; exports.rule = entities.Issue.onSchedule({ title: 'Raise priority from "Major" to "Critical" if not resolved in 10 days', search: '#Unresolved priority:Major', cron: '0 5 8 1/1 * ? *', guard: (ctx) => { return ctx.issue.created < Date.now() - days(10); }, action: (ctx) => { ctx.issue.fields.Priority = ctx.Priority.Critical; }, requirements: { Priority: { type: entities.EnumField.fieldType, Major: {}, Critical: {} } } });

Raise priority from "Critical" to "Show-stopper" if not resolved in 12 days

The next module contains an on-schedule rule that changes the priority of an issue from Critical to Show-Stopper if it is not resolved after 12 days. The rule runs daily starting at 08:30.

const entities = require('@jetbrains/youtrack-scripting-api/entities'); const days = require("./date-utils").days; exports.rule = entities.Issue.onSchedule({ title: 'Raise priority from "Critical" to "Show-stopper" if not resolved in 12 days', search: '#Unresolved priority:Critical', cron: '0 30 8 1/1 * ? *', guard: (ctx) => { return ctx.issue.created < Date.now() - days(12); }, action: (ctx) => { ctx.issue.fields.Priority = ctx.Priority.ShowStopper; }, requirements: { Priority: { type: entities.EnumField.fieldType, Critical: {}, ShowStopper: { name: 'Show-stopper' } } } });

date-utils

The last module contains a simple utility module that defines the days function. This function is used in each rule to calculate the difference between the current date and the due date.

exports.days = function days(count) { return count * 24 * 3600 * 1000; };
Last modified: 08 March 2021