You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hi All,
Currently I'm creating groovy script that will copy project's issue type screen scheme, keeping hierarchy of issue type screen scheme eg.
Issue Type screen scheme
Screen scheme
Field Screen -Create, EDIT, View
I find some method to do that but its not working.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.scheme.SchemeEntity
import com.atlassian.jira.issue.fields.screen.FieldScreen
import com.atlassian.jira.issue.fields.screen.FieldScreenScheme
import com.atlassian.jira.issue.fields.screen.FieldScreenSchemeManager
import com.atlassian.jira.issue.issuetype.IssueType
def projectKey = "PROJ" // replace with the project key
def newSchemeName = "Clone of ${projectKey} Issue Type Screen Scheme"
// get the ProjectManager, IssueTypeScreenSchemeManager, and FieldScreenManager
def projectManager = ComponentAccessor.getProjectManager()
def issueTypeScreenSchemeManager = ComponentAccessor.getIssueTypeScreenSchemeManager()
def fieldScreenManager = ComponentAccessor.getFieldScreenManager()
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
// get the existing issue type screen scheme for the project
def project = projectManager.getProjectObjByKey(projectKey)
if (project == null) {
log.error("Project not found: ${projectKey}")
return
}
def scheme = issueTypeScreenSchemeManager.getIssueTypeScreenSchemeFor(project)
if (scheme == null) {
log.error("Issue Type Screen Scheme is null for project ${projectKey}")
return
}
// clone the issue type screen scheme
def newScheme = issueTypeScreenSchemeManager.copyIssueTypeScreenScheme(scheme)
newScheme.setName(newSchemeName)
issueTypeScreenSchemeManager.createIssueTypeScreenScheme(newScheme, currentUser)
// clone the screens for the new scheme
scheme.getEntities().each { SchemeEntity schemeEntity ->
if (schemeEntity.isOfType(IssueType.class)) {
def issueType = schemeEntity.getEntity()
def existingScreen = schemeEntity.getScheme()
def newScreenName = "Clone of ${existingScreen.getName()} for ${newSchemeName} (${issueType.getName()})"
def newScreen = fieldScreenManager.copyFieldScreen(existingScreen)
newScreen.setName(newScreenName)
fieldScreenManager.createFieldScreen(newScreen)
// associate the new screen with the new scheme and issue type
def newEntity = newScheme.getEntities().find { it.getEntity()?.getId() == issueType?.getId() }
if (newEntity == null) {
log.error("Issue Type ${issueType?.getName()} not found in new Issue Type Screen Scheme")
return
}
newEntity.setScheme(newScreen)
issueTypeScreenSchemeManager.updateIssueTypeScreenSchemeEntity(newEntity, currentUser)
}
}