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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.