How to update "team" field of child using automation
Asked by daniel.nordal:

I have created an automation to "create stories with sub-tasks when creating epic" -\> picture 1. The idea behind the automation is to build logical structure for work flow and resource management.

Epic = Project

Story = Key Milestone

Sub-Task = Daily objectives/induvial tasks of any key milestone

Now, I am trying to assign an individual team to each Story -\> picture 2. However, when I use the "edit issue fields" it only updates the Epic and not the Story. The JSON code works just fine for updating the "teams field" but it updates the Epic and not the Story. I only want to update the "teams filed" of the Story and not the Epic.

![Rule1.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/337844i7B7879C241AAA8A2/image-size/large?v=v2&px=999 "Rule1.PNG")![Rule2.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/337845i398BFE2B1DFD6027/image-size/large?v=v2&px=999 "Rule2.PNG")


Answers:
author: daniel.nordal
body: [@Anandhi Arumugam](/t5/user/viewprofilepage/user-id/5552450) I didn't see your answer but I figured it out by trail and error... maybe this will help others in the future, but you are correct. In order to update stories within Epics you must create a branch and assign the branch to the "most recently created issue" and then you can use the same "edit issues field" as shown in the original post. You duplicate the branch for each Story in the chain. Also remember to use the correct "Team ID", this can be found at the end of the URL of each teams page.

![Rule3.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/337882iA8AF97054C412F82/image-size/large?v=v2&px=999 "Rule3.PNG")

comments: author: Bill Sheboy
body: Hi [@daniel.nordal](/t5/user/viewprofilepage/user-id/5552418) -- Welcome to the Atlassian Community!

For the rule you show, why not set that field at the same time the Story is created? The advanced edit with JSON is available in the Issue Create action

The branch to most recently created issue would then be needed only to create the Subtasks under the new story.

Kind regards,  
Bill


author: daniel.nordal
body: [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) I had not thought of that... but it also works and I have confirmed it works... and it is a much cleaner automation. It even has improved the runtime of the automation.

Automation with branch method - 25s runtime

Automation with JSON in Story - 22s runtime

![Rule4.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/338065iAB4AA6883569E19B/image-size/large?v=v2&px=999 "Rule4.PNG")

Also, I did not need to use branch for Sub-Tasks as you mentioned. I expect this is because I have created a "New Variable" before creating Sub-Task which allows this automation to run correctly. For fun I have changed the automation to use branches for Sub-Tasks under Stories and removed the (Re-fetch and New Variable) Commands. For this the runtime has improved further to 20s (picture below). Basically, this seems to be a more simple automation for Jira to run. Thankyou.

![Rule5.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/338068i7B97CBE04480D23A/image-size/large?v=v2&px=999 "Rule5.PNG")


author: Anandhi Arumugam
body: Hey [@daniel.nordal](/t5/user/viewprofilepage/user-id/5552418) Use a branch/related issues and pick Stories (or other issues in the Epic) to update the Story's fields. Hope this works for you.