Jira: Create a Script fragment button to create a story

miller j October 23, 2017

I need to Create a Script fragment to create a story. This button should be on epic screen.

When the button is clicked, the create issue screen should have epic link field populated by the epic link on which the button has been clicked(i.e like when the Sub task's parent field is populated when you click create sub task button on an issue screen)

1 answer

0 votes
Herbert Pratis December 17, 2020

I'm trying to do the same thing, i've linked my script fragment to a behaviour. Here's my code in the behaviour:

import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
def issueManager = ComponentAccessor.getIssueManager()
def contextIssue = issueManager.getIssueObject(getContextIssueId())

if (getBehaviourContextId() == "create-story-in-epic-link") {
getFieldById("project-field").setReadOnly(true)
getFieldById("issuetype-field").setReadOnly(true)

def epicLinkCf = customFieldManager.getCustomFieldObjectByName("Epic Name")
def linkedEpic = contextIssue.getCustomFieldValue(epicLinkCf) as Issue
getFieldByName("Epic Link").setFormValue(linkedEpic).setReadOnly(true)

}

 

The button is created properly, when i click on it, it triggers the Story popup creation screen, but it did not load the Epic key/name in the Epic Link :

any idea whats missing in my code?

thanks in advance!

2020-12-17_16-51-56.png

Suggest an answer

Log in or Sign up to answer