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 L```istener 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
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')