Is there a way to rename issuetypescheme using groovy script or other.

I was able to rename the other entities using groovy but not finding any method to rename the issuetypescheme.

Any help regarding the method for renaming issuetypescheme would be helpful.

Thanks in advance

2 answers

1 accepted

3 votes
Henning Tietgens Community Champion Oct 09, 2013

I think you have to use FieldConfigSchemeManager.updateFieldConfigScheme(FieldConfigScheme scheme), because the IssueTypeScheme is a FieldConfigScheme. But I don't tested that.

It does not give me an option of supplying the new name.

Also I have tried FieldConfigScheme.Builder.setName(" New Scheme Name ").toFieldConfigScheme()

Then supplying the above scheme to the FieldConfigSchemeManager.updateFieldConfigScheme(FieldConfigScheme scheme)

But , it is giving me a Null pointer probably because FieldConfigScheme.Builder.setName(" New Scheme Name ").toFieldConfigScheme() changes the object reference to another scheme which does not exist in the Jira Instance.

It would be great if you test the code and Help me.

Are there any other options available if this cannot be done through groovy.

Thanks in advance

Henning Tietgens Community Champion Oct 09, 2013

Ok, I tried the following and it works.

import com.atlassian.event.api.EventPublisher
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.ClearCacheEvent
import com.atlassian.jira.issue.fields.config.FieldConfigScheme
import com.atlassian.jira.issue.fields.config.manager.FieldConfigSchemeManager
import com.atlassian.jira.issue.fields.config.manager.IssueTypeSchemeManager
import com.atlassian.jira.project.ProjectManager

IssueTypeSchemeManager issueTypeSchemeManager = ComponentAccessor.getIssueTypeSchemeManager()
ProjectManager projectManager = ComponentAccessor.getProjectManager()
FieldConfigSchemeManager fieldConfigSchemeManager = ComponentAccessor.getComponent(FieldConfigSchemeManager)
EventPublisher eventPublisher = ComponentAccessor.getComponent(EventPublisher)

def project = projectManager.getProjectObjByKey('TST')
def its = issueTypeSchemeManager.getConfigScheme(project)
def its_new = (new FieldConfigScheme.Builder(its)).setName(its.name + ' 2').toFieldConfigScheme()
fieldConfigSchemeManager.updateFieldConfigScheme(its_new)
eventPublisher.publish(ClearCacheEvent.INSTANCE)
its = issueTypeSchemeManager.getConfigScheme(project)
return its.name

It appends " 2" to the IssueTypeScheme name of the IssueTypeScheme used by the TST project. After the change it seems that the cache has to be cleared to make the change visible. I don't know if this is the way it should be done, but it works.

Thats a nice catch ... I never thought of clearing the cache (I must admit).

I will try it again and see if it is working.

Thanks a ton .... :)

Greatly appreciate your help.

Thanks,

Sumit

You should definitely mark Henning's answer as correct seeing as he's gone to the trouble of writing some code, and even testing it (!). This kind of thing is a non-trivial amount of effort.

the above code is working absolutely fine as expected... I

added eventPublisher.publish(ClearCacheEvent.INSTANCE) line in my code and it worked fine.

Is there any specific reason why this rename was possible only after the ClearCacheEvent.INSTANCE.

For other entities the rename was happening fine without firing any such event {Just for curiosity}

Thanks,

Sumit

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,310 views 14 20
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot