YouTrack Standalone 2021.2 Help

Notify When Dependency Resolved

This workflow sends notification to the assignee of an issue when a dependant issue is resolved.

Name@jetbrains/youtrack-workflow-notify-when-dependency-resolved
Auto-attachedno
ModulesNotify assignee when an issue linked as "required for" is resolved (on-change rule)

Use Case

This workflow lets a user know when one of the issues that they are waiting on is resolved.

Modules

This rule checks the status of any issues that are linked as required for. If a linked issue is resolved, the assignee of the blocked issue is notified.

Notify assignee when an issue linked as "required for" is resolved

const entities = require('@jetbrains/youtrack-scripting-api/entities'); const workflow = require('@jetbrains/youtrack-scripting-api/workflow'); exports.rule = entities.Issue.onChange({ title: 'Notify assignee when an issue linked as "required for" is resolved', guard: (ctx) => { const issue = ctx.issue; return issue.fields.isChanged(ctx.State) && issue.fields.State && issue.fields.State.isResolved && (!issue.fields.oldValue(ctx.State) || !issue.fields.oldValue(ctx.State).isResolved); }, action: (ctx) => { if (ctx.issue.links['is required for'].isNotEmpty()) { const getLinkToIssue = function (i) { return '<a href="' + i.url + '">' + i.id + '</a> ' + '<a href="' + i.url + '">' + i.summary + '</a>'; }; ctx.issue.links['is required for'].forEach(function (dependent) { const assignee = dependent.fields.Assignee; const state = dependent.fields.State; if (assignee && assignee.login !== ctx.currentUser.login && (!state || !state.isResolved)) { const subject = workflow.i18n('[Youtrack, Required issue is resolved]'); const body = [ workflow.i18n('Dear assignee of {0}.', getLinkToIssue(ctx.issue)), '<br>', workflow.i18n('I\'m pleased to inform you that the issue required for your work - ' + '{0} - just has been resolved.', getLinkToIssue(dependent)), '<p style="color: gray; font-size: 12px; margin-top: 1em; border-top: 1px solid #D4D5D6">', workflow.i18n('Sincerely yours, YouTrack'), '</p>' ].join('\n'); assignee.notify(subject, body, true); } }); } }, requirements: { State: { type: entities.State.fieldType }, Assignee: { type: entities.User.fieldType }, Depend: { type: entities.IssueLinkPrototype, name: 'Depend', outward: 'is required for', inward: 'depends on' } } });

Last modified: 08 March 2021