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
No, the label field is supposed to allow multiple values
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Nic Brough -Adaptavist- can you help me here script which only allows 1 value in labelmanagercustomfield please?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.