Behaviour on label field in jira



I would like to add new labels to label field based on the issue type.

I want to use behaviour plugin to do so.

I already applied this script in a post function on first transition in a workflow (after create):

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.label.LabelManager
def user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()

LabelManager labelManager = ComponentAccessor.getComponent(LabelManager)
def labels = labelManager.getLabels({it.getLabel()}
labels += 'Incident'



And it works fine.

But I want this functionality be set as a behavior of a field for few issue type (not associated with specific transition of the workflow, and also updated when the issue is moved to the different issue queue-there will be few categories of the labels depending on issue type, like "incident", "service request", "project"). Can you please advise how I can rewrite this code to be useful as a server site script?



1 answer


I have looked into this issue it turns out that it is not possible to set the value of the Labels field using the Behaviours module of Script Runner. I have enclosed a screenshot from the Script Runner documentation showing that this is not possible.

labels bug.png

A support ticket has been created for this issue can be viewed at GRV-918.

For the meantime I would suggest you keep using the code above using post functions to add labels. You could use the example if statement code in your post function to check if the issue is of a certain type and if so only add labels for that issue type.

// Repeat the if statement for each issue type that needs to be checked for
if ( == "Task"){
// Add Label code here

I hope this helps


Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 13, 2019 in Marketplace Apps

Marketplace Spotlight: Marketing apps for Confluence to keep your teams working on the same page


247 views 0 6
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you