Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Global Tools October 9, 2013

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
Answer accepted
Henning Tietgens
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 9, 2013

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

Global Tools October 9, 2013

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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 9, 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.

Like Volodymyr Havryliuk likes this
Sumit Kumar
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 9, 2013

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

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 10, 2013

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.

1 vote
Sumit Kumar
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 10, 2013

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 Sign up to answer