Post a comment when an item is split

📘

How to apply this rule?

Post a comment to the original item when it is split

By default when you split an item into two, only one of them gets a comment:

1278 1279

With this automation rule, the second item will get a comment too:

1261 1138
[
  {
    "type": "source:targetprocess:EntityChanged",
    "entityTypes": [
      "comment"
    ],
    "modifications": {
      "created": true,
      "deleted": false,
      "updated": false
    }
  },
  {
    "type": "filter:Relational",
    "or": [
      {
        "and": [
          {
            "target": {
              "type": "field",
              "name": "Description",
              "target": {
                "type": "pipelineBlockOutput"
              }
            },
            "value": {
              "type": "constant",
              "value": "Original entity id:"
            },
            "operator": {
              "type": "contains"
            }
          }
        ]
      }
    ]
  },
  {
    "type": "action:JavaScript",
    "script": "const id = parseInt(args.Current.Description.replace(\"Original entity id:\", \"\"));\nif (isNaN(id)) { return }\n\nreturn {\n  command: \"targetprocess:CreateResource\",\n  payload: {\n    resourceType: \"Comment\",\n    fields: {\n      General: { Id: id },\n      Description: \"Split to id:\" + args.Current.General.Id,\n      Owner: { Id: args.Current.Owner.Id }\n    }\n  }\n};\n\n\n"
  }
]