Send overdue features to Slack

πŸ“˜

How to apply this rule?

920

🚧

Warning: sample URLs!

Please make sure to replace https://hooks.slack.com/services/xxxxx/yyyyyy/zzzzzzzzztGRAKwHLfm4kw with your Slack Webhook URL and https://youraccount.tpondemand.com/ with your Targetprocess URL

[
  {
    "type": "source:schedule",
    "schedule": {
      "kind": "interval",
      "unit": "hour",
      "value": 24
    }
  },
  {
    "type": "action:JavaScript",
    "script": "const api = context.getService(\"targetprocess/api/v2\");\n\n//get the list of overdue features\nconst features = await api.queryAsync(\"Feature\", {\n  select: \"{id, name}\",\n  where: `plannedEndDate < dateTime.parse('${args.fireTime}') and endDate == null`\n});\n\n//IMPORTANT: Change the account name below\nconst featureLinks = features.map(feature => {\n  return `<https://youraccount.tpondemand.com/entity/${feature.id}|${feature.name}>`;\n});\n\n//IMPORTANT: Update Slack link below\nreturn {\n  command: \"SendHttpRequest\",\n  payload: {\n    url: \"https://hooks.slack.com/services/xxxxx/yyyyyy/zzzzzzzzztGRAKwHLfm4kw\",\n    body: {\n      text: `Overdue features:\\n ${featureLinks.join('\\n')}`,\n      username: \"TP\"\n    }\n  }\n};"
  }
]