This article describes how to avoid the creation of a second issue by the Create issue(s) post-function when the same transition is triggered a second time. For example, if you are using a Create Issue(s) post-function on the "Escalate" transition of a support workflow to create a separate "Escalation" ticket, you will want to avoid re-creating a new "Escalation" ticket if the Escalate transition is run a second time in the lifetime of the support request.
...
Panel borderColor black title Check for the number of linked issues If you know that the current issue cannot have more than one issue linked to it through the link type configured on the "Link to new issue" option, then you can identify the existence of the issue similar to the one being created by checking for the number of issues linked to the current issue with the specific link type.
Steps to follow:
In the Conditional execution section of the post-function write the following script
Code Block issue.getLinkedIssues("caused by").size() == 0
The post-function will execute only when there are no issues linked to the current issue through the "caused by" link type.
Panel borderColor black title Check for the number of linked issues and specific characteristics of the created issue If you know that the current issue can have more than one issue linked to it through the link type configured on the "Link to new issue" option, but has unique characteristics, such as the same Summary as the current issue, then you can identify the existence of the issue similar to the one being created by finding an issue linked to the current issue with the specific link type and Summary same as the current issue.
Steps to follow:
In the Conditional execution section of the post-function write the following script:
Code Block !(issue.getLinkedIssues("blocks").any{ it.summary == issue.summary })
You can also use the
searchIssues
filter to find the issue having characteristics similar to the issue being created.Code Block jqlSearch("project = Test and issue in linkedIssues(" + issue.key + ",blocks) and summary ~\"" + issue.summary + "\"",1) == null
The post-function will execute only when there are no issues linked to the current issue through the "blocks" link type and with a Summary same as the current issue.
Panel borderColor black title Set an issue entity property and run the post-function based on its value Another approach is to set an issue entity property the first time the transition is run, and verify its value in the conditional execution of the post-function.
Steps to follow:
In the Conditional execution section Post-creation script of the Create issue post-function write , add the following Groovy script:
Add the Set issue, user or project Entity Property valueCode Block issue.getEntityPropertysetEntityProperty("New issue created") == null
, newIssueKey)
In the Conditional execution section of the Create issue post-function
to the same transition.Set the Current issue property,New issue created
toYes.
write the following script:
Code Block issue.getEntityProperty("New issue created") == null
The post-function will execute only when the current issue does not have an issue entity property with key "New issue created".
...