Forums

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

How can I use addProjectAssociations() to update the Issuetype scheme of a list of projects.

Jeremy Jedlicka January 24, 2023

I have a list of over 100 projects that are earmarked for archival and are the only projects in the applicable Issue Type Scheme.  I'm trying to move these projects into a similar scheme that doesn't require any Issue mapping. 

Trying to use Scriptrunner I'm attempting to use the method: 

addProjectAssociations()

 found in the documentation here: IssueTypeSchemeService (Atlassian JIRA - Server 8.0.0 API), but I keep getting a "groovy.lang.MissingMethodException: No signature of method:" error.

Any help would be appreciated.

Here is my code for reference:

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.issuetype.IssueType
import com.atlassian.jira.project.Project
import org.apache.log4j.Category

def projectManager = ComponentAccessor.getProjectManager()
def issueTypeSchemeManager = ComponentAccessor.getIssueTypeSchemeManager()
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def Category log = Category.getInstance("")

log.setLevel(org.apache.log4j.Level.DEBUG)

def projects = "RDCALERTS"

def serviceOutcome = issueTypeSchemeManager.addProjectAssociations(loggedInUser, 21300, projects)

if
(serviceOutcome.isValid()) {
    log.info("Issue Scheme Updated")
} else {
    log.error("Update failed: ${serviceOutcome.getErrorCollection().errors}")
}

1 answer

0 votes
Nic Brough -Adaptavist-
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.
January 24, 2023

Welcome to the Atlassian Community!

I think that's because you are passing a string into the call with "projects".  The call is expecting a list (even if it is a list of one item!)

Jeremy Jedlicka January 25, 2023

@Nic Brough -Adaptavist- 

It doesn't seem to matter, I can use 

def projects = ["ProjectID"] 

and it will still give me an error.

It says the proposed solution is to:
Possible solutions: addProjectAssociations(com.atlassian.jira.issue.fields.config.FieldConfigScheme, java.util.Collection)

but this isn't a field configuration change, so Im not sure why it wants me to use that.

Nic Brough -Adaptavist-
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.
January 27, 2023

That is not an array or collection.

Try forcing the type by dropping down into Java, such as

String[] cars = {"Volvo", "BMW", "Ford", "Mazda"}; 

Suggest an answer

Log in or Sign up to answer