Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Workflows stop working after renaming with scriptrunner script.

Chris Dunne _Raledo_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
February 21, 2018


We have a lot of workflows and wanted to rename them to a new naming convention. We used a scriptrunner script to rename the workflows. The rename was successful and no errors were reported.

But after the rename none of the existing issues could be transitioned - there were no actions available on the issue detail screen. However the status is correctly displayed, and the View Workflow link next to the status works and shows the correct workflow diagram and name. There are no conditions on the workflow transitions that would prevent the action buttons from showing.

When we view the project settings all the issue type to workflow mappings are correct, and workflow scheme seems to be correctly setup.

I've run the integrity checker, and re-indexed all issues.

I understand that you do not support ScriptRunner, but I don't think this is an issue with the add-on. I think it may be an issue with how we are using the APIs of the various classes used.

If we create a new issue, the workflows are working correctly.

The relevant section of code is as follows:

for(int i = 0; i < issueTypes.size(); i++)
def issueTypeName = issueTypes[i].name;
log.warn("Processing Issue Type ${issueTypeName}");
workflow = workflowManager.getWorkflow(projectId, issueTypes[i].id);
workflowName = workflow.getName();
def hyphenpos = 0;
def newName
for(int w=0; w< actionWords.size(); w++)
hyphenpos = issueTypeName.lastIndexOf(actionWords[w]);
StringBuilder builder = new StringBuilder();
builder.append(issueTypeName.substring(hyphenpos + 2));
newName = "(${projectKey}) ${builder.toString()}"
if(forPreview) {
log.warn("Dry run - no updates will be performed --- Renaming Workflow from [${workflowName}] to {${newName}}"); }
if(!forPreview) {
log.warn("Renamed Workflow from [${workflowName}] to {${newName}}");

I suspect that although the rename was successful, the link between the issues and the workflow is somehow corrupted and the issue is still somehow referencing the old workflow name.

In the logs I see errors like the following when viewing an issue

com.opensymphony.workflow.FactoryException: Unknown workflow name


2 answers

Suggest an answer

Log in or Sign up to answer
1 vote
Nathan Neulinger July 15, 2023

I put together something based on the above discussion, would love to hear back if anyone thinks there are potential issues or anything "incorrect" about it:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.workflow.WorkflowManager
import com.atlassian.jira.project.ProjectManager
import com.atlassian.jira.issue.IssueManager

import com.atlassian.jira.user.util.UserManager
import org.apache.log4j.Logger
import org.apache.log4j.Level

def log = Logger.getLogger("scriptrunner-rename-workflow")

def workflowManager = ComponentAccessor.getComponent(WorkflowManager)
def userManager = ComponentAccessor.getComponent(UserManager)
def projectManager = ComponentAccessor.getComponent(ProjectManager)
def issueManager = ComponentAccessor.getComponent(IssueManager)

def adminUserName = "nneulinger"
def oldName = "Business Support Workflow"
def newName = "Support Workflow"

workflow = workflowManager.getWorkflow(oldName)

updatedIssues = 0

if ( workflow ) {"Got workflow for " + oldName)

    user = userManager.getUserByName(adminUserName)

    workflowManager.updateWorkflowNameAndDescription(user, workflow, newName, workflow.getDescription())

    projectManager.projects.each { project ->"Processing project " + project.getKey())

        needsUpdate = 0
        project.getIssueTypes().each { issuetype ->
            issueWorkflow = workflowManager.getWorkflow(project.getId(), issuetype.getId());
            if ( issueWorkflow.getName() == newName ) {
      "  project issue type " + issuetype.getName() + " uses affected new workflow " + issueWorkflow.getName())

        if ( needsUpdate == 0 ) {
  "  no use of affected workflow in project, skipping")
        } else {
            issueManager.getIssueIdsForProject( { issueId ->
                final issue = issueManager.getIssueObject(issueId)
                final workflow = workflowManager.getWorkflow(issue)

      "  Checking issue " + issue.getKey() + ". Issue workflow is: " + workflow.getName())
                if ( workflow.getName() == oldName ) {
          "    Processing issue " + issue.getKey() + " in old workflow " + workflow.getName())
                    workflowManager.migrateIssueToWorkflow(issue, workflow, issue.status)
                else if ( workflow.getName() == newName ) {
          "    Processing issue " + issue.getKey() + " in new workflow " + workflow.getName())
                    workflowManager.migrateIssueToWorkflow(issue, workflow, issue.status)
} else {
    log.warn("Did not find workflow for " + oldName)

return updatedIssues

0 votes
Jan Ulrich Robens September 28, 2022

We stumbled upon the same issue and it seems that

// Migrate all issues to new workflows
projectManager.projects.each { project ->
issueManager.getIssueIdsForProject( { issueId ->
final issue = issueManager.getIssueObject(issueId)
final workflow = workflowManager.getWorkflow(issue)

workflowManager.migrateIssueToWorkflow(issue, workflow, issue.status)

at the end seems to "update" the issues to be usable again.

AUG Leaders

Atlassian Community Events