Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,558,949
Community Members
 
Community Events
184
Community Groups

How to set limit in Labels field to only one Label ?

In Labels field, it allows more than one label to be chosen or created & added.

Instead, wondering if there's a possibility to just allow only one label to be chosen from existing ones or create only one New label

Also, either by System " Labels " field or Custom Labels field, either way, if above limit can be set.

Thoughts & ideas, much appreciated.

TYIA

 

3 answers

Tried below in an behavior, doesn't restrict for one label
Any thoughts much appreciated.

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.IssueManager;
import com.opensymphony.workflow.InvalidInputException;
import org.apache.log4j.Logger


def issueManager = ComponentAccessor.getIssueManager()
def labelsField = underlyingIssue.getLabels()
if (labelsField.size() > 1){
   log.info("Please select only one project in 'Labels' field: " + labelsField)  
 throw new InvalidInputException("Please select only one project in Labels field")
}
0 votes
Hernan Halabi - Elite IT Consulting Group
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Jun 24, 2020

@Lokesh what you can possibly do is to set a condition that checks that the field has a single value. I recall doing that for the components field. That would get the work done but will cause headaches to the users because most likely they won't know why they can't transition the issue. Also, they can transition the ticket with a single value and then add a second value again so it's not the most reliable solution

@Hernan Halabi - Elite IT Consulting Group Not sure why you related transition may get impacted. Trying to understand a bit. Maybe if Component/s or Labels field is workflow validators, maybe that would be the case. 

Also, wondering how do you set a condition to check for single value ?. By any groovy expression ?

Hernan Halabi - Elite IT Consulting Group
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Jun 25, 2020

I recall using a condition option that checked that, no groovy expression. I believe the option said field has a single value might be part of an app. Most likely JMWE or Jira suite utilities.

Yes, its from JMWE, but its Validator. This checks during transitions. What's required is whenever Labels field is updated for more than one value, then it should stop user. Instead, prompt with error to include only one value.

Tried something as below in an behavior, but this doesn't seem to work nor log anything.

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.customfields.option.LazyLoadedOption;
import com.atlassian.jira.issue.fields.CustomField;
import com.onresolve.jira.groovy.user.FieldBehaviours;
import com.onresolve.jira.groovy.user.FormField;
import com.opensymphony.workflow.InvalidInputException;
import org.apache.log4j.Logger

def issueManager = ComponentAccessor.getIssueManager()
def labelsField = getFieldByName("Labels").getLabel()
if (labelsField.size() > 1){
InvalidInputException Err = new InvalidInputException("Please select only one project in ' Labels ' field")
log.info("Please select only one project in ' Labels ' field" + labelsField)
throw Err
}

Wondering what's missing here !!

Any clue ?

Hernan Halabi - Elite IT Consulting Group
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Jun 29, 2020

Can't help you with that part, sorry

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jun 24, 2020

No, you can't do this with labels.  It's pretty much the opposite of what they were designed for.

The functionality you describe can be done though - create a custom field of type "select" - you can control the list of options and only allow one to be used (if you want to select many, use a multi-select)

Select list fields (Single or Multi select) are fixed list fields for an user and need to depend on Admin to add any new options/values

While Labels does allow for adding new options/values, it allows more than one to added into it. 

Required is feature mix of both Select & Labels fields. 

This may require new plugin to develop, if no other way out ?

Like # people like this

Completely agree with Lokesh.
We are sitting with the exact same UseCase.
Users need to be able to create these "On The Fly", but they are only allowed to add 1.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events