Pull data from sub-tasks and input the total in a parent ticket field

Issue #395 resolved
alexlwilson created an issue

I'm working on an Inventory Management solution in JIRA and am trying to find a way to use the plugin to take the "Current Quantity" from a child ticket(s) and input the total in a "Current Quantity" field in the parent ticket.

There are two child tickets per parent ticket that would need to be added together.

Is there a way to do this using the plugin?

Comments (8)

  1. Fidel Castro Armario repo owner

    Hi Alex,

    A pair of questions:

    1. Is Current Quantity a number custom field?
    2. Is child - parent relation a subtask - parent issue relation, or are they linked to parent issue with a specific issue link type?

    It can be done using a post-function in the workflow of child issue or the parent issue. For example, we can add a post-function in "Create Issue" transition of child's workflow, in order to update parent's Current Quantity. This approach can be suitable if field Current Quantity is set at child issue creation.

  2. alexlwilson reporter

    Fidel,

    1. Yes, the Current Quantity field is configured as a number field.
    2. The relationship is task to sub-task.
  3. Fidel Castro Armario repo owner

    More questions:

    1. Do you want Current Quantity in parent issue to be updated by a post-function in parent, or in sub-task workflow?
    2. Is Current Quantity in subtasks set at issue creation?
    3. Can Current Quantity in subtasks be edited?
  4. alexlwilson reporter
    1. I would like it to be in the sub-task workflow so that quantities are refreshed more often.
    2. Current quantity is set when the user transitions the ticket from a "Unverified" to "Verified" status.
    3. "Current Quantity" can currently be edited without transitioning it, but this is something I'd like to change, since all scripts are either run using a listener or in a Post-Function.
  5. Fidel Castro Armario repo owner

    Add "Mathematical and date-time expression calculator" to transition from "Unverified" to "Verified" statuses in your subtasks' workflow, using the following configuration:

    Captura de pantalla 2016-08-17 a las 19.36.01.png

    Formula is:

    sum(fieldValue({nnnnn}, subtasks(%{00041})))
    

    replacing nnnnn with field code for Current Quantity in your particular JIRA instance.

    Note that %{00041} is field code for Parent's issue key.

  6. alexlwilson reporter

    What would need to change to have the parent ticket calculate the values from both sub-tasks and then return that in its "Current Quantity" field?

  7. Fidel Castro Armario repo owner

    Use the following formula in parent's workflow:

    sum(fieldValue({nnnnn}, subtasks()))
    
  8. Log in to comment