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 create a new category scheme with the pre-defined set of categories.

import com.atlassian.jira.component.ComponentAccessor
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
import com.atlassian.jira.user.util.UserUtil

// Initializing the app components

@WithPlugin("com.stiltsoft.jira.smart-attachments")
SmartAttachmentsFacade facade = ScriptRunnerImpl.getPluginComponent(SmartAttachmentsFacade)
UserManager userManager = ComponentAccessor.getUserManager()

// Specifying the user on the behalf of who the scheme will be created
def currentUser = userManager.getUserByName("admin")

// Specifying the name of a new category scheme
def scheme = facade.createScheme("New Scheme", currentUser)

// Specifying names of categories within the category
def categoryDocuments = facade.generateNewConfigCategory("Documents")
def categoryScreenshots = facade.generateNewConfigCategory("Screenshots")
def categoryLogs = facade.generateNewConfigCategory("Logs")
def categoryPrototypes = facade.generateNewConfigCategory("Prototypes")

// Creating new categories within the category scheme
scheme.categories.add(categoryDocuments)
scheme.categories.add(categoryScreenshots)
scheme.categories.add(categoryLogs)
scheme.categories.add(categoryPrototypes)

// Updating the category scheme and saving modifications
facade.updateScheme(scheme, currentUser)
  • No labels