Hi,
I'm looking for a a solution to change the issue type from an existing issue by using script runner / groovy.
I've found the following script, but the issue isn't updated:
import org.apache.log4j.Category
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.issuetype.IssueType
// Define a Logger
def Category log = Category.getInstance("com.onresolve.jira.groovy.PostFunction")
log.setLevel(org.apache.log4j.Level.DEBUG)
def constantsManager = ComponentAccessor.getConstantsManager()
//Test
//def issueManager = ComponentAccessor.getIssueManager()
//def issue = issueManager.getIssueObject("JIRA-1234")
Issue issue = issue
IssueType targetIssueType = null
log.debug "IssueType old = " + issue.issueType.name
collection = constantsManager.getAllIssueTypeObjects()
iterator = collection.iterator()
while(iterator.hasNext()){
issueType = iterator.next()
if(issueType.name == "Kleinstauftrag"){
targetIssueType = issueType
}
}
log.debug targetIssueType.name
issue.setIssueTypeObject(targetIssueType)
log.debug "IssueType new = " + issue.issueType.name
The log shows the new issue type but when i reload the issue it's still the old value. I do not understand why the change is not saved.
I'm running the code in the script console.
Best regards
Manuel