Category Mappings
Behaviours are mapped to projects (and optionally issue types within projects) or service desks (optionally request types). To map a behaviour to several related projects, map to project categories rather than individual projects. Map behaviours to a project category using a Custom Listener to update mappings using a simple API.
Set up a Global listener to handle a ProjectCategoryChangeEvent, and add as many category mappings as required (project or service desk mappings). When a project has a category added or removed, the event handler fires, and mappings relevant to that category are updated.
Create a Custom Listener to update mappings
- In Note, enter a description for the listener, for example, Update Mappings.
- Select Global to apply the listener to all projects on your instance.
- Select ProjectCategoryChangeEvent in Events.
Add a script to the Script field specifying the project category and behaviour. See below for some script examples.
If there is more than one behaviour with the same name, only one of them is updated (the first). Please check your behaviour names before attempting this and edit where necessary.
Examples
To map all projects in My Category to a behaviour named My Behaviour:
import com.onresolve.jira.behaviours.BehavioursCategoryMappingService
import com.onresolve.scriptrunner.runner.customisers.PluginModule
@PluginModule
BehavioursCategoryMappingService categoryMappingService
categoryMappingService.categoryProjectMapping(event, 'My Category', 'My Behaviour')
To map just issue types Bug and Task in projects in My Category to a behaviour named My Behaviour:
import com.onresolve.jira.behaviours.BehavioursCategoryMappingService
import com.onresolve.scriptrunner.runner.customisers.PluginModule
@PluginModule
BehavioursCategoryMappingService categoryMappingService
categoryMappingService.categoryProjectMapping(event, 'My Category', 'My Behaviour', 'Bug', 'Task')
To create a service desk mapping to all service desk projects in My Category to a behaviour named My Behaviour:
import com.onresolve.jira.behaviours.BehavioursCategoryMappingService
import com.onresolve.scriptrunner.runner.customisers.PluginModule
@PluginModule
BehavioursCategoryMappingService categoryMappingService
categoryMappingService.categoryServiceDeskMapping(event, 'My Category', 'My Behaviour')
To create a service desk mapping for request types Employee exit and New employee, to all service desk projects in My Category to a behaviour named My Behaviour:
import com.onresolve.jira.behaviours.BehavioursCategoryMappingService
import com.onresolve.scriptrunner.runner.customisers.PluginModule
@PluginModule
BehavioursCategoryMappingService categoryMappingService
categoryMappingService.categoryServiceDeskMapping(event, 'My Category', 'My Behaviour', 'Employee exit', 'New employee')