Close all children when the parent was closed

📘

If an item has multiple final states, it will be moved to the default final state

📘

How to apply this rule?

Close all Task when User Story was closed

Filter by Project.Name is optional

912
[
  {
    "type": "source:targetprocess:EntityChanged",
    "entityTypes": [
      "UserStory"
    ],
    "modifications": {
      "created": false,
      "deleted": false,
      "updated": [
        "EntityState"
      ]
    }
  },
  {
    "or": [
      {
        "and": [
          {
            "target": {
              "type": "field",
              "name": "Name",
              "target": {
                "type": "field",
                "name": "Project",
                "target": {
                  "type": "pipelineBlockOutput"
                }
              }
            },
            "value": {
              "type": "constant",
              "value": "Custom Development"
            },
            "operator": {
              "type": "is"
            }
          },
          {
            "target": {
              "type": "field",
              "name": "IsFinal",
              "target": {
                "type": "field",
                "name": "EntityState",
                "target": {
                  "type": "pipelineBlockOutput"
                }
              }
            },
            "value": null,
            "operator": {
              "type": "is true"
            }
          }
        ]
      }
    ],
    "type": "filter:Relational"
  },
  {
    "type": "action:JavaScript",
    "script": "const api = context.getService(\"targetprocess/api/v2\");\nconst tasks = await api.queryAsync(\"Task\", {\n  select: \"id\",\n  where: \"entitystate.isfinal=false and userstory.id=\" + args.ResourceId\n});\nif (!tasks) { return; }\n\nreturn tasks.map(task => {\n  return {\n    command: \"targetprocess:MoveToState\",\n    payload: {\n      resourceId: task,\n      resourceType: \"Task\",\n      stateKind: \"Final\"\n    }\n  };\n})"
  }
]

Close all User Stories when Feature was closed

Filter by Project.Name is optional

905
[
  {
    "type": "source:targetprocess:EntityChanged",
    "entityTypes": [
      "Feature"
    ],
    "modifications": {
      "created": false,
      "deleted": false,
      "updated": [
        "EntityState"
      ]
    }
  },
  {
    "or": [
      {
        "and": [
          {
            "value": {
              "type": "constant",
              "value": "Custom Development"
            },
            "target": {
              "name": "Name",
              "type": "field",
              "target": {
                "name": "Project",
                "type": "field",
                "target": {
                  "type": "pipelineBlockOutput"
                }
              }
            },
            "operator": {
              "type": "is"
            }
          },
          {
            "value": null,
            "target": {
              "name": "IsFinal",
              "type": "field",
              "target": {
                "name": "EntityState",
                "type": "field",
                "target": {
                  "type": "pipelineBlockOutput"
                }
              }
            },
            "operator": {
              "type": "is true"
            }
          }
        ]
      }
    ],
    "type": "filter:Relational"
  },
  {
    "type": "action:JavaScript",
    "script": "const api = context.getService(\"targetprocess/api/v2\");\nconst children = await api.queryAsync(\"UserStory\", {\n  select: \"id\",\n  where: \"entitystate.isfinal=false and feature.id=\" + args.ResourceId\n});\nif (!children) { return; }\n\nreturn children.map(id => {\n  return {\n    command: \"targetprocess:MoveToState\",\n    payload: {\n      resourceId: id,\n      resourceType: \"UserStory\",\n      stateKind: \"Final\"\n    }\n  };\n})"
  }
]

Close all Features when Epic was closed

Filter by Project.Name is optional

911
[
  {
    "type": "source:targetprocess:EntityChanged",
    "entityTypes": [
      "Epic"
    ],
    "modifications": {
      "created": false,
      "deleted": false,
      "updated": [
        "EntityState"
      ]
    }
  },
  {
    "or": [
      {
        "and": [
          {
            "value": {
              "type": "constant",
              "value": "Custom Development"
            },
            "target": {
              "name": "Name",
              "type": "field",
              "target": {
                "name": "Project",
                "type": "field",
                "target": {
                  "type": "pipelineBlockOutput"
                }
              }
            },
            "operator": {
              "type": "is"
            }
          },
          {
            "value": null,
            "target": {
              "name": "IsFinal",
              "type": "field",
              "target": {
                "name": "EntityState",
                "type": "field",
                "target": {
                  "type": "pipelineBlockOutput"
                }
              }
            },
            "operator": {
              "type": "is true"
            }
          }
        ]
      }
    ],
    "type": "filter:Relational"
  },
  {
    "type": "action:JavaScript",
    "script": "const api = context.getService(\"targetprocess/api/v2\");\nconst children = await api.queryAsync(\"Feature\", {\n  select: \"id\",\n  where: \"entitystate.isfinal=false and epic.id=\" + args.ResourceId\n});\nif (!children) { return; }\n\nreturn children.map(id => {\n  return {\n    command: \"targetprocess:MoveToState\",\n    payload: {\n      resourceId: id,\n      resourceType: \"Feature\",\n      stateKind: \"Final\"\n    }\n  };\n})"
  }
]