modify the JIRA Agile Story screen

I modified the out of the box New Feature to be part of the Agile Scrum Issue Type Scheme and it is now linked to an Epic. How do I change the Story Issue type to link to the New Feaure instead of an Epic

1 answer

You can do that using the Script Runner Plugin (https://marketplace.atlassian.com/plugins/com.onresolve.jira.groovy.groovyrunner)

so in the post-function of the create issue, just connect your script. HerE's an exemple of a script who will create an issue of issuetype X with a Epic Link:

import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.Issue
import org.ofbiz.core.entity.GenericValue
import com.atlassian.jira.config.SubTaskManager
import com.atlassian.jira.bc.project.component.ProjectComponent
import com.atlassian.jira.project.Project
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.fields.config.FieldConfig
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLinkType
import com.atlassian.jira.issue.link.IssueLinkTypeManager
import com.atlassian.jira.project.ProjectManager
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.issue.label.LabelManager
Summary = ["Prototype - Blocking Scripted Event", "Prototype - Blocking Animation" ]
IssuetypeID = "3"
components = ["Cinema","FX"]
 
ComponentManager componentManager = ComponentManager.getInstance()
CustomFieldManager cfManager = componentManager.getCustomFieldManager()
ProjectManager projectMgr = ComponentManager.getInstance().getProjectManager()
SubTaskManager subTaskManager = componentManager.getSubTaskManager()
IssueLinkManager linkMgr = ComponentManager.getInstance().getIssueLinkManager()
OptionsManager optionsManager = ComponentManager.getComponentInstanceOfType(OptionsManager.class)
IssueLinkTypeManager issueLinkTypeManager = ComponentManager.getComponentInstanceOfType(IssueLinkTypeManager.class)
 
def component
def user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
def issueFactory = componentManager.getIssueFactory()
def issueManager = componentManager.getIssueManager()
def indexManager = componentManager.getIndexManager()
def watcherManager = ComponentAccessor.getWatcherManager()
def userManager = ComponentAccessor.getUserManager()
CustomField cfMilestone = cfManager.getCustomFieldObjectByName("Milestone")
CustomField cfUbi = cfManager.getCustomFieldObjectByName("Ubi")
Issue parentissue = issue;
LabelManager labelManager = ComponentAccessor.getComponent(LabelManager)
Project project = parentissue.getProjectObject()
reporter = componentManager.getJiraAuthenticationContext().getUser()
currentUser = componentManager.getJiraAuthenticationContext().getUser()
i = 0
Summary.each {String summary ->
    try
    {
        normalIssue = issueFactory.getIssue()
        MutableIssue newIssue = normalIssue as MutableIssue
        newIssue.issueTypeId = IssuetypeID
        component = componentManager.getProjectComponentManager().findByComponentName(project.getId(),components[i])
        newIssue.setComponentObjects([component])
        newIssue.summary = parentissue.summary + " | " + summary
        newIssue.reporter = reporter
        newIssue.setAssignee(ComponentManager.instance.userUtil.getUserObject(component.getLead()))
        newIssue.setCustomFieldValue(cfUbi, parentissue.getCustomFieldValue(cfUbi))
        newIssue.setCustomFieldValue(cfMilestone, parentissue.getCustomFieldValue(cfMilestone))
        newIssue.setProject(parentissue.getProjectObject().genericValue)
        //Map<String, Object> newIssueParams = ["issue": newIssue] as Map<String, Object>
        Params = ["issue": newIssue]
        GenericValue newIssueDone = issueManager.createIssue(currentUser, Params)
        labelManager.addLabel(user, newIssueDone.id, 'cinema_task', false)
        //indexManager.reIndex(newIssue);
        indexManager.reIndex(newIssueDone);
        breakintoLinkType = null
        Collection cloneIssueLinkTypes = issueLinkTypeManager.getIssueLinkTypesByName("Epic-Story Link")
        for (Iterator iterator = cloneIssueLinkTypes.iterator(); iterator.hasNext();) {
            IssueLinkType issueLinkType = (IssueLinkType) iterator.next();
            if (issueLinkType.getName() == "Epic-Story Link") {
                breakintoLinkType = issueLinkType.getId();
            }
        }
        linkMgr.createIssueLink(parentissue.id, newIssue.id, breakintoLinkType, 0, currentUser)
        indexManager.reIndex(newIssue);
        indexManager.reIndex(parentissue);
    }
    catch (exception)
    {
        log.warn(exception.message)
    }
    i = i + 1
}

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Sarah Schuster
Posted Mar 28, 2018 in Jira Software

Can a company’s culture make or break agile adoption?

Can a new-to-agile team survive and thrive in a non-agile culture? If so, what advice would you give to those trying to be agile in a non-agile culture? What's the key(s) to success? Share your thoug...

12,060 views 15 13
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you