期限日
このワークフローは、課題を解決する期限を設定できます。
ユースケース
このワークフローでは、すべての報告者が課題を解決する期日を設定し、課題が期限切れになると担当者に通知する必要があります。
このワークフローを使用するには、プロジェクトに期限日フィールドを追加するか、別の日付型フィールドを作成して、デフォルトワークフローの期限日フィールドへの参照を変更する必要があります。
このワークフローは、もともと送信済み要求(JT-5998(英語))から取得されました。
この課題を送信したユーザーは、すべての新しい課題に必要なフィールドを作成して、レポートの基礎として使用できるようにしたいと考えていました。
ルール
最初のモジュールには、期日が設定されていない限り、課題の作成を防ぐルールが含まれています。期限日フィールドが空の場合、警告が表示されます。
このルールを簡単に変更して、プロジェクトの 1 つ以上のカスタムフィールドの値を要求できます。ただし、ルールが正しく機能するには、必須フィールドで空の設定にすることができますが有効になっている必要があります。詳細については、https://www.jetbrains.com/help/youtrack/cloud/?Attaching-Custom-Fields-to-Projects を参照してください。
提出された課題の期日を要求する
最初に、ルールは課題が報告されていないことを確認します。これは、ユーザーがまだ課題を作成中または課題の下書きで作業しているときに警告が表示されることを意味します。true の場合、required メソッドで期限日フィールドの値をチェックします。
const entities = require('@jetbrains/youtrack-scripting-api/entities');
const workflow = require('@jetbrains/youtrack-scripting-api/workflow');
exports.rule = entities.Issue.onChange({
title: 'Require due dates for submitted issues',
guard: (ctx) => {
return ctx.issue.becomesReported;
},
action: (ctx) => {
ctx.issue.fields.required(ctx.DueDate, 'You must set the Due date!');
},
requirements: {
DueDate: {
type: entities.Field.dateType,
name: 'Due Date'
}
}
});
期限切れの課題について担当者に通知する
2 番目のモジュールには、10:00 の期限日フィールドの値をチェックするルールが含まれています。課題が期限切れで未割り当ての場合、プロジェクト所有者に通知が送信されます(ここでは issue.project.leader として参照されます)。課題が割り当てられている場合、通知が割り当て先に送信されます。
const entities = require('@jetbrains/youtrack-scripting-api/entities');
const workflow = require('@jetbrains/youtrack-scripting-api/workflow');
const dateTime = require('@jetbrains/youtrack-scripting-api/date-time');
exports.rule = entities.Issue.onSchedule({
title: 'Notify assignee about overdue issues',
search: '#Unresolved has: {Due Date}',
cron: '0 0 10 ? * MON-FRI',
guard: (ctx) => {
return ctx.issue.fields.DueDate < Date.now();
},
action: (ctx) => {
const issue = ctx.issue;
let userToNotify = issue.fields.Assignee;
if (!userToNotify) {
userToNotify = issue.project.leader;
}
const formattedDate = dateTime.format(issue.fields.DueDate);
const notificationText = 'Issue became overdue on <i>{0}</i>:', formattedDate +
' <a href="' + issue.url + '">' + issue.summary + '</a><p style="color: gray;font-size: 12px;margin-top: 1em;border-top: 1px solid #D4D5D6">' +
'Sincerely yours, YouTrack' + '</p>';
userToNotify.notify('[YouTrack, Issue is overdue]', notificationText);
},
requirements: {
DueDate: {
type: entities.Field.dateType,
name: 'Due Date'
},
Assignee: {
type: entities.User.fieldType
}
}
});
2026 年 7 月 06 日