Calculate Capacity of Team Iteration automatically based on previous Velocities | Targetprocess - Enterprise Agility Solution

Calculate Capacity of Team Iteration automatically based on previous Velocities

Planning capacity for future Team Iteration based on previous periods is quite a typical case among our customers. Scrum Masters, Managers, or Team Leads normally calculate each team’s average points completed per Team Iteration over the last N months and use that average as a starting point for the next time-boxes. There is no more need to calculate capacity externally. The following article will help to automate this process using Targetprocess Automation Rules functionality.

Use Case

AS a Scrum Master
WHEN I create a new Team Iteration card, average Velocity from last 5 Team Iteration is calculated and set to "Capacity" field of new Team Iteration automatically. If some Team Iteration has 0, it is not taken into account and does not influence the calculation.
SO THAT I do not need to make it manually.


  • Navigate to Settings -> Automation rules -> Raw Json View
    Targetprocess Image

  • Copy and paste the following piece of code:

        "type": "source:targetprocess:EntityChanged",
        "entityTypes": [
        "modifications": {
          "created": true,
          "deleted": false,
          "updated": false
        "type": "action:JavaScript",
        "script": "const teamId = args.Changed.Team.Id;\n\nconst api = context.getService(\"targetprocess/api/v2\");\nconst querySpec = {\n  select: \"{velocity}\",\n  take: 5,\n  where: \"velocity > 0 and =\" + teamId\n};\n\nconst teamiterations = await api.queryAsync(\"TeamIteration\", querySpec);\n\nconst avgVelocity = teamiterations.reduce((acc, value) => acc + value.velocity, 0) / teamiterations.length;\n\nreturn {\n  command: \"targetprocess:UpdateResource\",\n  payload: {\n    resourceType: \"TeamIteration\",\n    resourceId: args.ResourceId,\n    fields: {\n      Capacity: avgVelocity\n    }\n  }\n};\n\n"

  • Add description and save the rule
    Targetprocess Image

Still have a question?

We're here to help! Just contact our friendly support team

Find out more about our APIs, Plugins, Mashups and custom extensions. Join our community of passionate users and even discuss directly with our developers.

Or contact
a sales representative

Get a live
product demo

Let one of our product specialists create your account
and shape Targetprocess for your company needs.