Branch rule in already existing branch
Asked by Anders Ottosson:

Hello!

I'm creating automation in Jira and are currently creating a story with my rule.

Under that story I want one or more sub-tasks to be created.

Under some sub-tasks I want Acceptance Criteria's to be created.

The creation of the Story works fine.

Branch rule (For most recent created issue) works fine to create all the sub-task in the story.

But to create the Acceptance Criteria's under the sub-tasks I would need another Branch rule to import the template for the Acceptance Criteria's. But it is not possible to create a Branch rule in the 2nd level when creating automations. It is only possible in the 1st level.

Anyone know how to do this in an easy way?


Answers:
author: John Funk
body: Hi Anders - Welcome to the Atlassian Community!

Please share your rule here so we can give you better guidance.

comments: author: Anders Ottosson
body: Hello and thanks for quick response.

Enough to share a screenshot or you want me to export the rule and post here? If screenshot enough, here it goes.

The issue with the below is that the Accept. Criteria's is placed in the Story and not the Sub-task.

I've tried to add the Accept. Crit. as a component in directly in the Sub-task when creating the rule, but it is not part of the components available.

![2024-08-09_13h02_20.png](https://community.atlassian.com/t5/image/serverpage/image-id/340968iE6273706CEFEFAB9/image-size/large?v=v2&px=999 "2024-08-09_13h02_20.png")


author: Marc - Devoteam
body: Hi [@Anders Ottosson](/t5/user/viewprofilepage/user-id/5564542)

So this is not a Custom Test field where you add data.

This action is from a marketplace app, what app are you using?

It might be that this field can be filled within the creation of the subtask, or add a re-fetch action in between the creation and the import template


author: Anders Ottosson
body: Yes "Import template" is a 3rd party extension. Someone added it to our Jira installation and it works when importing templates (where import our Accept. Crit. and Definition of Done from. I did not add the plugin called "Import template", so I'm not sure exactly what app it is. But it works when adding Acceptance Criteria's to issues.

The reason I'm using it and not adding the filed and populating it through "Choose fields to set..." is that the Acceptance Criteria's we are using is a list of checkboxes and that field is not available when searching for it under "Choose fields to set...".

The "Import template" plugin form looks like this:

![2024-08-09_13h57_49.png](https://community.atlassian.com/t5/image/serverpage/image-id/340985iB901A1BD87AD8E8B/image-size/large?v=v2&px=999 "2024-08-09_13h57_49.png")

How would I do a "re-fetch action in between the creation and the import template"?

The optimal solution would be to be able to add a new branch after the creation of the sub-task and put the "Import template" in that. But as mentioned in the original question, adding branch seems only to be possible in the 1st level and not in the 2nd level.

Sorry if I'm not answering your questions the way you like, but Jira is a bit new for me.


author: Marc - Devoteam
body: Hi [@Anders Ottosson](/t5/user/viewprofilepage/user-id/5564542)

There is no second branch option.

In the actions list their is a re-fetch option.

<https://support.atlassian.com/cloud-automation/docs/jira-automation-actions/#Re-fetch-issue-data>

What is the 3rd party app that is used?


author: John Funk
body: You can create the Sub-task right after the Story and not need to put it under a Branch. For the parent, you can use {{createdissue.key}}


author: Bill Sheboy
body: Hi [@Anders Ottosson](/t5/user/viewprofilepage/user-id/5564542) -- Welcome to the Atlassian Community!

Adding to John's suggestion about directly adding subtasks without branching, I recommend first saving the created Story's key in a variable. That will help if adding multiple subtasks.

For example:

* trigger: issue created
* action: re-fetch issue *(I recommend always re-fetching after the Issue Created trigger to prevent racetrack errors.)*
* condition: summary contains *Anders test*
* action: create issue for the Story
* action: create variable, saving the {{createdIssue.key}}
* action: create issue for a Subtask, setting the *parent* field to the variable
* branch: to most recently created issue (In this case, the subtask)
  * action: Import template
* *... repeat the above 3 steps for as many subtasks are needed*

Kind regards,  
Bill


author: Anders Ottosson
body: Hello everyone!

The "Re-fetch issue data" and then create a new sub-task with this in "Additional fields" solved it:

{  
"fields": {  
"parent": {  
"key": "{{createdIssue.key}}"  
}  
}  
}

Thank you all for helping out with this. The bullet point list from [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) was the one that got everything in place for me.

Thanks,

Anders


author: John Funk
body: Great! Glad to hear.


author: Marc - Devoteam
body: Hi [@Anders Ottosson](/t5/user/viewprofilepage/user-id/5564542)

Welcome to the community.

As [@John Funk](/t5/user/viewprofilepage/user-id/7148) mentions share your rule.

But if Acceptance Criteria is a field in the subtasks, you can set this field with content on creation of the issue.

Just state the information in the field when creating the subtasks.


Tags: data-center

jira-data-center