Check out our Cloud apps to improve your experience in Jira and Confluence Cloud.
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
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()) {

def scheme = optionalScheme.get()

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

facade.updateScheme(scheme, currentUser)
  • No labels