How to check if an issue exists in an EPIC and create it if it does not exist
Asked by Kaps:

Hi,

I have a manual automation rule that creates a set of issues linked in unique ways between one another when an EPIC is created. I have over time, updated the rule where the latest version of the rule creates additional issues in the EPIC compared to the previous rule versions. I'm now trying to create a rule to check if there are missing issues in existing EPICs that used an older version of the rule, and if so, create the missing issues for the given EPIC to match what the current rule does.

I'm facing two problems  

1. I'm able to add 'For issues in EPIC' branch however, I cannot check in that branch if an issue is missing by checking for a particular summary and if so, create it; basically can't add nested branches  

2. I'm unable to use exact phrase checks for the summary of an issue in any of the SQL conditions; basically, the (\\) escape character for quotes doesn't work as mentioned in your documentation for an advanced SQL


Answers:
author: Mykenna Cepek
body: For item 1: it would help to have more detail. Consider posting a screenshot of that portion of the rule. Conditional/Branch nesting is a known limitation of Jira Automation. The typical workaround is to "unroll the nesting". In your case, perhaps a JQL-based conditional could check for the missing issue and set a variable. Then refer to that variable later in the branch.

For item 2: exact search in Jira/JQL is not currently supported (despite the documentation).

Refer to [JRACLOUD-69263](https://jira.atlassian.com/browse/JRACLOUD-69263) and please vote for it!

comments: author: Kaps
body: Thanks for the update [@Mykenna Cepek](/t5/user/viewprofilepage/user-id/3527113) .

I did try to paste an image when creating this question however, it didn't work.

Will try to add it again.


author: Kaps
body: Here is a snippet of the rule I have been trying to put together  

![Jira_Issue.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/169782i0CC13CC9F5C7475E/image-size/large?v=v2&px=999 "Jira_Issue.jpg")

The idea was to loop through all the issues of the EPIC and set a variable to indicate the issue with a certain summary was not found. Then, later check the variable and if the issue was not found, create the issue and add it to the EPIC


author: Kaps
body: I guess the main thing I need to do is check the summary of the issue but, if exact phrases cannot be checked then I assume that means there is no solution available?


author: Mykenna Cepek
body: Exact phrases cannot be checked currently, and just today I noticed that the priority of the related JAC issue (linked earlier in this thread) was unfortunately decreased.

However, just because JQL doesn't support it doesn't mean that Jira Automation can't make an exact check -- it can. It'll just take a bit more work in the rule. For example, just add another *conditional* that checks the specific field name (e.g. Summary) against the text. I think that's what you meant to do instead of the "Issue Matches JQL" conditional shown above.

Another factor that may impact your goal here is that Jira Automation doesn't naturally support an algorithm which loops to update a variable, and then later checks that variable. In short, that just doesn't work, because for performance reasons Automation will execute the loop content in parallel threads, leading to non-deterministic behavior with the variable.


author: Kaps
body: Thanks [@Mykenna Cepek](/t5/user/viewprofilepage/user-id/3527113)

It makes sense,

As you suggested earlier, I'm able to get it to work now by using the "If Related Issues Condition" with a JQL that checks for most of the summary name. Still some bits and pieces to do but don't see any major blockers now!