How to allow only single value in label manager dropdown?

Ronak June 6, 2020

Hi,

I have label manager defined with multiple values as drop down. I have made it mandatory filed using behaviors. 

My query is- How to allow user to select only 1 value in that labelManagerCustomField? Currently it is allowing selection from dropdown.

Thanks,

Ronak

1 answer

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.
June 6, 2020

No, the label field is supposed to allow multiple values

Ronak June 6, 2020

Thanks Nic, Is there a way any script can help? behaviors or listeners?

Ronak June 6, 2020

It is not easy to change label manager to custom filed now. Many of jira issues have product field with different values.

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.
June 6, 2020

You could use a behaviour to stop multiple selections on create, edit and transition, but that would be ignored by REST, boards and other edit functions.

I would go back to asking "why".  Labels are supposed to be multiple use.  What problem are you trying to solve by inflicting single-options here?  Why are you not using a single select list to categorise the issues?

Like Joe Pitt likes this
Ronak June 7, 2020

It was created since a year now as label manager. It suppose be to custom field with single select. Now, requirement is only allow single value must be selected while at creating, or updating issue at any time. Already many issues have that filed associated now with different projects.

I tried following script in behaviors .  I know that is not correct script, however, I am not good developer and need help here  to allow only 1 value in labelmanagercustomfield. I believe listener will help here. Suggest me best option.

import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours

def formField = getFieldByName("Product Line")

def optionsManager = ComponentAccessor.getOptionsManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customField = customFieldManager.getCustomFieldObject(formField.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)
def optionToSelect = options.find {
it.value == "2FAEnforcement"
}
formField.setFormValue(optionToSelect.optionId)

Ronak June 10, 2020

@Nic Brough -Adaptavist-  can you help me  here script which only allows 1 value in labelmanagercustomfield please?

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.
June 10, 2020

No, I've never tried to do it that way because it's the wrong thing to do.  The power and use of a labels field is that it can contain many labels.

I would strongly recommend that you use a single-select field instead of trying to kludge the labels field. 

Ronak June 10, 2020

Okay. Thanks for assistance. I need to created custom field with single select value then and transit all existing value  from label manager to that newly field,

Suggest an answer

Log in or Sign up to answer