Create a set of Tasks under User Story based on a template

👍

This use case consists of two rules and is meant to replace Task Creator Plugin

📘

How to apply this rule?

When a new User Story with specific text in Name created, Create a set of Tasks for it

All Names can be modified further as per your needs

1882
[
  {
    "type": "source:targetprocess:EntityChanged",
    "entityTypes": [
      "UserStory"
    ],
    "modifications": {
      "created": true,
      "deleted": false,
      "updated": false
    }
  },
  {
    "or": [
      {
        "and": [
          {
            "value": {
              "type": "constant",
              "value": "Template"
            },
            "target": {
              "name": "Name",
              "type": "field",
              "target": {
                "type": "pipelineBlockOutput"
              }
            },
            "operator": {
              "type": "contains"
            }
          }
        ]
      }
    ],
    "type": "filter:Relational"
  },
  {
    "type": "action:targetprocess:CreateEntity",
    "fields": {
      "Name": {
        "type": "constant",
        "value": "Template Task 1"
      },
      "Project": {
        "name": "Id",
        "type": "field",
        "target": {
          "name": "Project",
          "type": "field",
          "target": {
            "type": "pipelineBlockOutput"
          }
        }
      },
      "UserStory": {
        "name": "Id",
        "type": "field",
        "target": {
          "type": "pipelineBlockOutput"
        }
      }
    },
    "entityType": {
      "type": "constant",
      "value": "Task"
    }
  },
  {
    "type": "action:targetprocess:CreateEntity",
    "fields": {
      "Name": {
        "type": "constant",
        "value": "Template Task 2"
      },
      "Project": {
        "name": "Id",
        "type": "field",
        "target": {
          "name": "Project",
          "type": "field",
          "target": {
            "type": "pipelineBlockOutput"
          }
        }
      },
      "UserStory": {
        "name": "Id",
        "type": "field",
        "target": {
          "type": "pipelineBlockOutput"
        }
      }
    },
    "entityType": {
      "type": "constant",
      "value": "Task"
    }
  },
  {
    "type": "action:targetprocess:CreateEntity",
    "fields": {
      "Name": {
        "type": "constant",
        "value": "Template Task 3"
      },
      "Project": {
        "name": "Id",
        "type": "field",
        "target": {
          "name": "Project",
          "type": "field",
          "target": {
            "type": "pipelineBlockOutput"
          }
        }
      },
      "UserStory": {
        "name": "Id",
        "type": "field",
        "target": {
          "type": "pipelineBlockOutput"
        }
      }
    },
    "entityType": {
      "type": "constant",
      "value": "Task"
    }
  }
]

When a new User Story with specific text in Name created, Create a set of Tasks for it with pre-defined Effort

This use case is more complex and requires using Javascript. We will need to replace Id for the Role in the code with the one we have specified for Tasks. Role Id can be checked under Settings->Roles

2143
[
  {
    "type": "source:targetprocess:EntityChanged",
    "entityTypes": [
      "UserStory"
    ],
    "modifications": {
      "created": true,
      "deleted": false,
      "updated": false
    }
  },
  {
    "or": [
      {
        "and": [
          {
            "value": {
              "type": "constant",
              "value": "EffortTemplate"
            },
            "target": {
              "name": "Name",
              "type": "field",
              "target": {
                "type": "pipelineBlockOutput"
              }
            },
            "operator": {
              "type": "contains"
            }
          }
        ]
      }
    ],
    "type": "filter:Relational"
  },
  {
    "type": "action:JavaScript",
    "script": "const userStoryId = args.Current.Id;\nconst projectId = args.Current.Project.Id;\nreturn {\n  command: \"targetprocess:UpdateResource\",\n  payload: {\n    resourceType: args.ResourceType,\n    resourceId: userStoryId,\n    fields: {\n      id: userStoryId,\n      Tasks: {\n        items:\n          [\n            {\n              Name: \"Template task with effort 1\",\n              RoleEfforts: { RoleEffort: { Role: { id: 9 }, Effort: 7 } }\n            },\n            {\n              Name: \"Template task with effort 2\",\n              RoleEfforts: { RoleEffort: { Role: { id: 9 }, Effort: 13 } }\n            }\n          ]\n      }\n    }\n  }\n};\n"
  }
]