How to update some custom field in task from JQL with a sub-task specific condition
Asked by Marco Atturio:

Hi Experts! :)

I have created several automations that add up the days of these split by component of the various sub-tasks, now these automations work correctly, and they start automatically any original estimate of a sub-task is edited it is updated on the relative parent task with the sum of the days of all the sub-tasks that have a certain components.

I'm posting the screens from the automation that works and that fires when I modify when any sub-task (in this example I'm going to update the "Gu Cedacri "custom field in task. Which contains the sum of the original estimates of the sub-tasks with "Cedacri" components for that specific task )

**Now I will to make an new automation that triggers manually that goes to update ALL the tasks massively based on specific sub-tasks condition**, this would be used to update the Gu "component name" fields (eg: Gu Cedacri, gu customtool etc ...) for all existing tasks.

I write here what I would like to do specifically:

1) I retrieve a certain number of TASK with a JQL (e.g.: project = COMPANIES and issuetype = Task and status != Closed)

2) Loop\\iterate on those tasks and for each task I go to do the sum of the original estimates present in the sub-tasks connected with the same component (e.g. task 1 has 3 sub-tasks of which 2 with Cedacri component and 1 with customtool component)

3) I get the sum of the days of those with Cedacri component and update the custom field present on the TASK "gu Cedacri" (if it were possible to update the other components as well (e.g.: gu customtool with the sum of the customtool components separately in order to create a single automation)

4) End of the cycle

![Immagine 09-06-23 - 11.06.jpeg](https://community.atlassian.com/t5/image/serverpage/image-id/262323iD2D4DA5C2DDBC91C/image-size/large?v=v2&px=999 "Immagine 09-06-23 - 11.06.jpeg")![Immagine 09-06-23 - 11.07.jpeg](https://community.atlassian.com/t5/image/serverpage/image-id/262324i9AD9223B4402F152/image-size/large?v=v2&px=999 "Immagine 09-06-23 - 11.07.jpeg")


Answers:
author: Bill Sheboy
body: Hi [@Marco Atturio](/t5/user/viewprofilepage/user-id/5113286)

From what you have described, you likely have all of the pieces you need to build such a rule. What have you tried thus far to do this?

Please note: rules have service limits to processing, so if you have many tasks (or many subtasks per task), the rule could exceed the limits. Please look here for more information: <https://support.atlassian.com/cloud-automation/docs/automation-service-limits/>

I suspect your basic rule would be something like this:

* trigger: manual
* branch: on JQL for the tasks
  * action: lookup issues to gather the subtasks...or access them directly using the subtasks smart value
  * action: edit the task for a specific issue Component, using the smart value list filtering and list functions
  * ...repeat for each possible issue Component

If you instead want a rule which could dynamically iterate over the components AND iterate over the tasks, that may not be possible as the rule would need nested branching...which is not a feature of rules.

Kind regards,  
Bill

comments: author: Marco Atturio
body: Thank you [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) ,

have been very busy during this time and I could not try your suggestion,

I will try as soon as possible and give you feedback


Tags: jira

jira-cloud