Check out our new apps for Jira Cloud and start free trial.
Skip to end of metadata
Go to start of metadata

This example illustrates the way to associate the project to the specific category scheme.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.project.ProjectManager
import com.atlassian.jira.user.util.UserManager
import com.onresolve.scriptrunner.runner.ScriptRunnerImpl
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.stiltsoft.jira.attachcategory.facade.SmartAttachmentsFacade

// Initializing the app components
@WithPlugin("com.stiltsoft.jira.smart-attachments")
SmartAttachmentsFacade facade = ScriptRunnerImpl.getPluginComponent(SmartAttachmentsFacade)
UserManager userManager = ComponentAccessor.getUserManager()
ProjectManager projectManager = ComponentAccessor.getProjectManager()

// Specifyng the category scheme for association with the project
def currentUser = userManager.getUserByName("admin")
def optionalScheme = facade.getSchemeByName("New Scheme")

// Interrupting the script execution if the scheme with such name does not exist
if (!optionalScheme.isPresent()) {
    return
}

def scheme = optionalScheme.get()

// Specifying the project key which the category scheme is associated with
def project = projectManager.getProjectByCurrentKey("ONE")
scheme.projects.add(project)

facade.updateScheme(scheme, currentUser)
  • No labels