Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
  • Community
  • Q&A
  • Jira
  • Questions
  • How can I hide field values of custom field ​​based on the value of another cf by Behaviour ?

How can I hide field values of custom field ​​based on the value of another cf by Behaviour ?

Artem Chechuha
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 11, 2020

Hi, guys. 
I need to hide field values of custom field ​​based on the value of another cf by Behaviour.

I have two Select List (single choice) fields: "Field 1P" and "Field 2W". 

"Field 2W" has such values: 
-Native
-Non-native

"Field 1P" has such values:
-1
-2
-3
-4
-5

I wan't that if I choose "Field 2W" = Native, i just see in "Field 1P" only "3" and "4", without other.


It's my code, but it doesn't work:

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.customfields.manager.OptionsManager

List<String> optionsA = ["3","4"]


def writer = getFieldByName("Field 2W");
String writer_value = writer.getValue();


def customField = getCustomFieldManager().getCustomFieldObjectByName("Field 1P")
def cf1 = getFieldByName("Field 1P")
OptionsManager optionsManager = ComponentAccessor.getOptionsManager()
def config = customField.getRelevantConfig(getIssueContext())
def ParticipationTypeMap = [null: "None"]

def options = optionsManager.getOptions(config)
if(writer_value.toString() == "native"){

ParticipationTypeMap += options.findAll {
it.value in optionsA
}.collectEntries {
[(it.optionId.toString()): it.value]
}

cf1.setFieldOptions(ParticipationTypeMap)
}

 

1 answer

0 votes
Chandrakanth
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 3, 2022

My requirement also same , can any one help on this scenario

Suggest an answer

Log in or Sign up to answer