Pull data from sub-tasks and input the total in a parent ticket field
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)
-
repo owner -
reporter Fidel,
- Yes, the Current Quantity field is configured as a number field.
- The relationship is task to sub-task.
-
repo owner More questions:
- Do you want Current Quantity in parent issue to be updated by a post-function in parent, or in sub-task workflow?
- Is Current Quantity in subtasks set at issue creation?
- Can Current Quantity in subtasks be edited?
-
reporter - I would like it to be in the sub-task workflow so that quantities are refreshed more often.
- Current quantity is set when the user transitions the ticket from a "Unverified" to "Verified" status.
- "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.
-
repo owner Add "Mathematical and date-time expression calculator" to transition from "Unverified" to "Verified" statuses in your subtasks' workflow, using the following configuration:
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.
-
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?
-
repo owner Use the following formula in parent's workflow:
sum(fieldValue({nnnnn}, subtasks()))
-
reporter - changed status to resolved
Thanks! That worked.
- Log in to comment
Hi Alex,
A pair of questions:
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.