how to use script runner to switch project workflow scheme

how to use groovy code to change the workflow scheme for a JIRA project?

The WorkflowSchemeManager doesn't provide a method to remove or add workflow scheme from JIRA project

3 answers

This widget could not be displayed.
Alexey Matveev Community Champion Nov 07, 2017

Hello,

Suppose, you want to set workflow scheme from the template project to another project. The code would be something like that:

Project project = ComponentAccessor.getProjectManager().getProjectObjByKey("projectKey");

Project templateProject = ComponentAccessor.getProjectManager().getProjectObjByKey("projectKey");

ComponentAccessor.getWorkflowSchemeManager().addSchemeToProject(project, ComponentAccessor.getWorkflowSchemeManager().getSchemeFor(templateProject));
This widget could not be displayed.
Steven Behnke Community Champion Nov 07, 2017

WorkflowSchemeManager extends SchemeManager. You have a addSchemeToProject() method.

This widget could not be displayed.

hi Alex,

I want to copy a workflow scheme from a template project and assign that copied workflow scheme to a new project. i tried your code, but it doesn't work. It remove the workflow scheme from both template and target project. When i go to admin page edit the template workflow scheme, the log shows the error below. 

2017-11-21 04:04:51,206 http-nio-8080-exec-21 ERROR admin 244x10835x1 wllipk 10.209.96.235 /rest/globalconfig/latest/workflowschemeeditor/11401 [c.a.p.r.c.error.jersey.ThrowableExceptionMapper] Uncaught exception thrown by REST service: Passed List had more than one value.
java.lang.IllegalArgumentException: Passed List had more than one value.
at org.ofbiz.core.entity.EntityUtil.getOnly(EntityUtil.java:62)
at com.atlassian.jira.workflow.DefaultWorkflowSchemeManager.getSchemeForProject(DefaultWorkflowSchemeManager.java:364)
at com.atlassian.jira.workflow.DefaultWorkflowSchemeManager.getSchemeForProject(DefaultWorkflowSchemeManager.java:358)
at com.atlassian.jira.workflow.DefaultWorkflowSchemeManager.getWorkflowMap(DefaultWorkflowSchemeManager.java:315)
at sun.reflect.GeneratedMethodAccessor934.invoke(Unknown Source)
... 1 filtered

,

 

Regards

hi BrianL,I met same error like yours. did you fix it ?

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Aug 06, 2018 in Jira Service Desk

A is for Activate: Share your top Jira Service Desk onboarding tips for new users!

Hi, everyone! Molly here from the Jira Service Desk Product Marketing Team :).  In the spirit of this month's  august-challenge, we're sourcing stories of Jira Service Desk activation fro...

573 views 25 15
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