Set Planned End Date based on Severity


How to apply this rule?

Set Planned End Date for Bugs based on their Severity

All Blocking bugs should be fixed within one day after their creation. For Critical bugs the delay is 2 days. And Normal bugs should be fixed during the next 5 days after their creation. There is no deadline for bugs with Severity Small or Enhancement.

820 1170
    "type": "source:targetprocess:EntityChanged",
    "entityTypes": [
    "modifications": {
      "created": true,
      "deleted": false,
      "updated": [
    "type": "action:JavaScript",
    "script": "const mapping = {\n  \"Blocking\": 1,\n  \"Critical\": 2,\n  \"Normal\": 5\n}\nconst delay = mapping[args.Current.Severity.Name];\n\nconst utils = require(\"utils\");\nconst end = delay ? utils.addDays(args.Current.CreateDate, delay) : null;\n\nreturn {\n  command: \"targetprocess:UpdateResource\",\n  payload: {\n    resourceType: args.ResourceType,\n    resourceId: args.ResourceId,\n    fields: {\n      PlannedEndDate: end\n    }\n  }\n};"