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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,551,670
Community Members
 
Community Events
184
Community Groups

Workflows stop working after renaming with scriptrunner script.

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

Hi

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]);
if(hyphenpos>0)
{
StringBuilder builder = new StringBuilder();
builder.append(issueTypeName.substring(0,hyphenpos));
builder.append(":");
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) {
wfService.updateWorkflowNameAndDescription(ctx,workflow,newName,workflow.getDescription())
log.warn("Renamed Workflow from [${workflowName}] to {${newName}}");
}
break;
}
}
 

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

 

1 answer

We stumbled upon the same issue and it seems that

// Migrate all issues to new workflows
projectManager.projects.each { project ->
issueManager.getIssueIdsForProject(project.id).each { 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.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events