In our project, one Jira issue of type Requirement is linked to n issues of type Functional Specification (FS). What I need is a button on a Requirement issue to create a FS issue and then link it automatically in a certain way to the Requirement issue.
By the way, we are still using Jira Server. We will probably move to Jira Cloud in some years (because Jira Server is discontinued), but I guess we will need to resolve this problem again when it happens.
Approaches:
issue.issueType.name == 'Requirement' && event.getComment().getBody().equals('createFS') && com.atlassian.jira.component.ComponentAccessor.getCommentManager().delete(event.getComment())
Jira administration → Manage apps → Fragments → Create Script Fragments → Constrained create issue dialog with
Name | Value | Remark |
---|---|---|
What section should this go in | operations-work |
to have the button respectively menu item it in the “More” menu of the current issue |
Key | create-linked-fs |
needed to be referenced in the second step |
Weight | 1 |
Place in the menu in case you specify more custom buttons |
Condition | issue.issueType.name == 'Requirement' |
matching type of current issue |
Issue Type | Functional Specification |
type of the new issue |
Behaviours → Add Behaviour
import com.atlassian.jira.component.ComponentAccessor
def issueManager = ComponentAccessor.getIssueManager()
if (getBehaviourContextId() == "create-linked-fs") {
getFieldById("project-field").setReadOnly(true)
getFieldById("issuetype-field").setReadOnly(true)
def contextIssue = issueManager.getIssueObject(getContextIssueId())
getFieldById("issuelinks-linktype").setFormValue("trace up to").setReadOnly(true)
getFieldById("issuelinks-issues").setFormValue(contextIssue.key).setReadOnly(true)
}