コメント内のリマインダー
警告: 自動化ルールから直接メールを送信することはできません。そのため、この回避策を使用し、@メンション付きのコメントを追加する必要があります。これにより最終的に実際のメールが送信されます。
所有者に、計画終了日が近づいていることをお知らせください

[
{
"type": "source:schedule",
"schedule": {
"kind": "interval",
"unit": "day",
"value": 1
}
},
{
"type": "action:JavaScript",
"script": "// how many days before the deadline this reminder should be send?\nconst days = 3;\nconst type = \"Task\";\n\nconst today = new Date();\nconst dow = today.getDay();\nif (dow == 6 || dow == 0) { return; } // it's a week-end. No notifications\nconst daysCount = (dow + days <= 5)\n ? days // it's the beginning of the week\n : days + 2; //it's the end of the week. We add 2 days to compensate the weekend\nconst date = ___PROTECTED_2___;\n\nconst api = context.getService(\"targetprocess/api/v2\");\nconst items = await api.queryAsync(type, {\n where: ___PROTECTED_3___,\n select: '{id,ownerName:Owner.fullname,ownerLogin:Owner.login,deadline:PlannedEndDate}'\n});\n\nreturn items.map(item => {\n let mentions = ___PROTECTED_4___;\n let plannedEnd = new Date(item.deadline);\n return {\n command: \"targetprocess:CreateResource\",\n payload: {\n resourceType: \"Comment\",\n fields: {\n General: { Id: item.id },\n Description: mentions + \", this item should be finished on \" + plannedEnd.toDateString()\n }\n }\n };\n})"
}
]
指定した日付に割り当てられたユーザーにリマインダーを送信する

[
{
"type": "source:schedule",
"schedule": {
"kind": "interval",
"unit": "day",
"value": 1
}
},
{
"type": "action:JavaScript",
"script": "const dateField = \"Notify On\";\nconst type = \"Task\";\nconst role = \"Reminder\";\n\nconst api = context.getService(\"targetprocess/api/v2\");\nconst items = await api.queryAsync(type, {\n where: ___PROTECTED_5___,\n select: ___PROTECTED_6___\n});\n\nreturn items\n .filter(item => item.users && item.users.length) // do nothing if there is noone assinged with specified role\n .map(item => {\n let mentions = item.users.map(user => {\n return ___PROTECTED_7___;\n }).join(\" and \");\n return {\n command: \"targetprocess:CreateResource\",\n payload: {\n resourceType: \"Comment\",\n fields: {\n General: { Id: item.id },\n Description: ___PROTECTED_8___\n }\n }\n };\n})"
}
]