YouTrack Standalone 2019.3 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 Title

Auto Raise Priority

Auto-attached

no

Modules

Raise 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.

var entities = require('@jetbrains/youtrack-scripting-api/entities'); var workflow = require('@jetbrains/youtrack-scripting-api/workflow'); var days = require("./date-utils").days; exports.rule = entities.Issue.onSchedule({ title: workflow.i18n('Raise priority from "Normal" to "Major" if not resolved in 7 days'), search: '#Unresolved priority:Normal', cron: '0 0 8 1/1 * ? *', guard: function(ctx) { return ctx.issue.created < Date.now() - days(7); }, action: function(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.

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

var entities = require('@jetbrains/youtrack-scripting-api/entities'); var workflow = require('@jetbrains/youtrack-scripting-api/workflow'); var days = require("./date-utils").days; exports.rule = entities.Issue.onSchedule({ title: workflow.i18n('Raise priority from "Critical" to "Show-stopper" if not resolved in 12 days'), search: '#Unresolved priority:Critical', cron: '0 30 8 1/1 * ? *', guard: function(ctx) { return ctx.issue.created < Date.now() - days(12); }, action: function(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: 16 March 2020