Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to hide options in a multi select field based on a radio button.

Jacob francois October 18, 2018

def Systemtype = getFieldById("customField_27600")
def Printer = getFieldByName("Printer/Scanner")
def other = getFieldByName("Other")

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()

def corp = getFieldByName("customField_27524")


def customField = customFieldManager.getCustomFieldObject(Systemtype.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)


if(corp.getValue() == "Corp")
{

def optionsMap = options.findAll {
it.value in ["Laptop", "Desktop", "Wacom Tablet", "Printer/Scanner", "Other", "Desk Phone", "Mobile","Conf Phone" ]
}.collectEntries {
[
(it.optionId.toString()) : it.value
]
}

Systemtype.setFieldOptions(optionsMap)

}
else
{
def optionsMap = options.findAll {
it.value in ["PC", "Printer/Scanner", "Other", "Desk Phone", "iPad","PDA" ]
}.collectEntries {
[
(it.optionId.toString()) : it.value
]
}

Systemtype.setFieldOptions(optionsMap)

}

 

 

Whats wrong here ? 

2 answers

0 votes
Alvin
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.
October 18, 2018

@Jacob francois , where are you hiding these options? on customer portal or on agent?

If on customer portal, mapped it to request type

If on agent , mapped it to issue type.

0 votes
Mark Markov
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.
October 18, 2018

Hello @Jacob francois

Your code looks good and should work.

Where do you place it? It should be attached to a Corp field.

Jacob francois October 18, 2018

I am placing it in the script runner behavior on the Corp field. 

Suggest an answer

Log in or Sign up to answer