Inherit Planned Dates from parents to children

📘

How to apply this rule?

Inherit Planned Dates from User Stories to Tasks when Task is added to User Story

[
  {
    "type": "source:targetprocess:EntityChanged",
    "entityTypes": [
      "task"
    ],
    "modifications": {
      "created": true,
      "deleted": false,
      "updated": [
        "UserStory"
      ]
    }
  },
  {
    "type": "action:targetprocess:UpdateEntity",
    "fields": {
      "PlannedEndDate": {
        "name": "PlannedEndDate",
        "type": "field",
        "target": {
          "name": "UserStory",
          "type": "field",
          "target": {
            "type": "pipelineBlockOutput"
          }
        }
      },
      "PlannedStartDate": {
        "name": "PlannedStartDate",
        "type": "field",
        "target": {
          "name": "UserStory",
          "type": "field",
          "target": {
            "type": "pipelineBlockOutput"
          }
        }
      }
    },
    "target": {
      "type": "pipelineBlockOutput",
      "blockAlias": "ui:source"
    }
  }
]

Inherit Planned Dates from User Stories to Tasks when User Story is updated

[
  {
    "type": "source:targetprocess:EntityChanged",
    "entityTypes": [
      "UserStory"
    ],
    "modifications": {
      "created": false,
      "deleted": false,
      "updated": [
        "PlannedEndDate",
        "PlannedStartDate"
      ]
    }
  },
  {
    "type": "action:JavaScript",
    "script": "const child = \"Task\";\nconst parent = args.ResourceType;\n\nconst api = context.getService(\"targetprocess/api/v2\");\nconst children = await api.queryAsync(child, {\n    select: \"id\",\n    where: `${parent}.id=${args.ResourceId}`\n});\nif (!children || !children.length) { return; }\n\nreturn children.map(id => {\n  return {\n    command: \"targetprocess:UpdateResource\",\n    payload: {\n      resourceType: child,\n      resourceId: id,\n      fields: {\n        PlannedStartDate: args.Current.PlannedStartDate,\n        PlannedEndDate: args.Current.PlannedEndDate\n      }\n    }\n  };\n});"
  }
]