Forums

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

Changing IssueTypeScreenScheme with Jira Data Center API

mobitech62_proton_me
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 31, 2024

Hello all,

I need to programmatically change a project's IssueTypeScreenScheme, on a Data Center 9.4 instance.

It seems like Data Center only supports REST API v2 (not v3), which doesn't have IssueTypeScreenScheme endpoints.

Is there another way to do it?

Thank you :)

1 answer

0 votes
Evgenii
Community Champion
January 31, 2024

Hi, @mobitech62_proton_me 

You can make it through Java API, which is available for on-prem instances. It has more functions, than REST API.

For you task there is special class, which changes issue type schemes. 

Here is example, how you can make it:

/*
* Created 2023.
* @author Evgeniy Isaenkov
* @github https://github.com/Udjin79/SRUtils
*/

package Examples.CleanupScripts

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.config.FieldConfigScheme
import com.atlassian.jira.issue.fields.config.manager.IssueTypeSchemeManager

// Obtaining the IssueTypeSchemeManager instance.
IssueTypeSchemeManager issueTypeSchemeManager = ComponentAccessor.getIssueTypeSchemeManager()

// Retrieving all field configuration schemes available in the Jira instance.
List<FieldConfigScheme> fieldConfigSchemes = issueTypeSchemeManager.getAllSchemes()
String report = ""

// Counter for the number of schemes processed.
Integer i = 0

// Iterating through each field configuration scheme.
fieldConfigSchemes.each { FieldConfigScheme scheme ->

// Checking if the scheme is not the default one and is not associated with any projects.
if (scheme.getName() != "Default Issue Type Scheme" && scheme.getAssociatedProjectObjects().size() == 0) {
// Appending the scheme name to the report.
report += "${scheme.getName()}<br/>"

// Incrementing the counter.
i++

// Deleting the scheme as it's unused.
issueTypeSchemeManager.deleteScheme(scheme)
}
}

// Returning a report containing the total number of deleted schemes and their names.
return "Total: ${i}<br/>" + report

issueTypeSchemeManager makes required operations.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events