Automation Issue fields condition of parent object within a branch.
Asked by Jeff Clay:

I'm running into an issue with an automation rule. What I'm trying to achieve is create an epic in another project (IT) with linked tasks based on values of a multi-select of a newly created epic in a different project (HR).

I've tried two different ways, here's screenshots of the settings right now and below a description of the other method I've tried.

![Screenshot from 2021-11-12 15-48-20.png](https://community.atlassian.com/t5/image/serverpage/image-id/169204iBB03C99BC6F92384/image-size/large?v=v2&px=999 "Screenshot from 2021-11-12 15-48-20.png")![Screenshot from 2021-11-12 15-50-41.png](https://community.atlassian.com/t5/image/serverpage/image-id/169205iA6AE52D09B2EA4F7/image-size/large?v=v2&px=999 "Screenshot from 2021-11-12 15-50-41.png")

As I'm sure you've noticed, the above only works if the all conditions of IT Hardware are selected. So, if an epic is created in HR and only "Docking Station" is selected, then the IT project will only get an epic without the linked task to provide the docking station.

I have tried putting the IT Hardware field condition within the branch. This resulted in none of the conditions being met since the branch was for "For Most recently created issue". I then changed the branch type to "Current Issue" which allowed the conditions to be met. However, that broke the "Due Date" and "Epic Link" values within the task. I was unable to link the task to the newly created IT epic since I was branching off of the HR epic for that task creation step.

Thank you in advance for any suggestions.


Answers:
author: Jeff Clay
body: I managed to work around this issue by putting the following automation rule in my IT project.

![Screenshot from 2021-11-15 11-29-10.png](https://community.atlassian.com/t5/image/serverpage/image-id/169409i1DEB90EEEFF8D213/image-size/large?v=v2&px=999 "Screenshot from 2021-11-15 11-29-10.png")

comments: author: Jeff Clay
body: Also, in my HR project rule, I went with the branch on current issue rule.

![Screenshot from 2021-11-15 11-34-43.png](https://community.atlassian.com/t5/image/serverpage/image-id/169410i5F815E498C14C815/image-size/large?v=v2&px=999 "Screenshot from 2021-11-15 11-34-43.png")


author: Mykenna Cepek
body: Try using the "If / else block" condition instead of an "Issue fields condition". That will ensure that execution continues even if the condition is not true.

Also, I'm noticing that your second "For most recently created issue" branch might misfire if the "Desk Phone" conditional causes a Task to be created. At that point, a new "most recently created issue" will be in effect.

To get around this, you'll want to put all your Task creation actions inside just one "For most recently created issue" branch. That should ensure they are created under the Epic created early in your rule.

Using pseudo-code, I envision your solution being more like this:

```
...
Action: Create Epic
Branch: For Most recently created issue
  If/Else Condition: if IT Hardware contains Desk Phone
    Then Action: Create Task
  If/Else Condition: if IT Hardware contains Docking Station
    Then Action: Create Task
```

comments: author: Bill Sheboy
body: Hi [@Jeff Clay](/t5/user/viewprofilepage/user-id/4314769)

Yes, and...to what Mykenna suggests:

Are you trying to:

1. create a task for each value in the multiselect fields in one rule, or
2. do you only expect one value to be selected for the multiselect field?

If it is the first one, you are gonna need a longer rule and to save the created epic's key to help. Otherwise only the first selected item in the list will be used (I think). For example:

* trigger: issue created in HR
* condition: issue type is Employee onboarding
* related issues condition: on your JQL
* action: create the new epic in IT
* action: create a variable to save the new IT epic's key
* branch: on JQL to match the saved IT epic's key from the variable
  * condition: trigger issues IT Hardware has *Phone*
  * action: create task
* branch: on JQL to match the saved IT epic's key from the variable
  * condition: trigger issues IT Hardware has *Docking Station*
  * action: create task
* ... add more branch/condition/creates

Please note that this rule will run slower due to all of the branches.

Kind regards,  
Bill


author: Mykenna Cepek
body: I believe the if/else condition does allow for checking if a multi-select field contains a value:

![Screen Shot 2021-11-12 at 5.48.34 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/169208i0AADFFA5D70D0EB3/image-size/large?v=v2&px=999 "Screen Shot 2021-11-12 at 5.48.34 PM.png")

Yes, I have a multi-select custom field called MultiSelectTest. We didn't have any multi-select fields, so I had to create one (months ago) to do some testing!


author: Jeff Clay
body: I've tried if/else but the problem with those is that after one rule matches the rest don't.


author: Mykenna Cepek
body: Hmmm. Perhaps the "Create Issue" action in the If/Else is altering what should be the "current issue" as the Epic specified in the branch. That sounds like a bug to me, but let's try to work around it...

Here is updated pseudocode that might get you going:

```
...
Action: Create Epic
Branch: For Most recently created issue
  Action: Create variable DeskPhone set to 0
 ?Action: Create variable DockingStation set to 0
  If/Else Condition: if IT Hardware contains Desk Phone
    Then Action: Create variable DeskPhone set to 1
  If/Else Condition: if IT Hardware contains Docking Station
    Then Action: Create variable DockingStation set to 1
  If/Else Condition: if {{DeskPhone}} is 1
    Then Action: Create Task
  If/Else Condition: if {{DockingStation}} is 1
    Then Action: Create Task
```

This approach postpones the creation of the Tasks.

Important: With all these If/Else conditions, be sure NOT to nest them. You don't want this:

```
? If/Else Condition: if IT Hardware contains Desk Phone
    If/Else Condition: if IT Hardware contains Docking Station
      If/Else Condition: if {{DeskPhone}} is 1
        If/Else Condition: if {{DockingStation}} is 1?
```


Tags: jira-cloud

jira-software