Forums

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

Behavior set cascading values

Omprakash Thamsetty
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 Champions.
June 6, 2019

Hi,

I am looking the way to set the cascading values based on Issue type.

I was able to do for single selection using below code but how to set the cascading field type values similar to single selection in behavior

 

import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.component.ComponentAccessor

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

// Get a pointer to my select list field
def selectList = getFieldByName("Activity Type")

// Get the issue type
//def ITName = underlyingIssue?.getIssueType().name
def ITName = issueContext.issueType.name


// Get access to the required custom field and options managers
//def customField = customFieldManager.getCustomFieldObject(selectList.getFieldId())
def fieldName = "Activity Type"
def field = getFieldByName(fieldName)
def customField = customFieldManager.getCustomFieldObjectByName(fieldName)
def fieldConfig = customField.getRelevantConfig(getIssueContext())

def options = optionsManager.getOptions(fieldConfig)

// Get the checkbox option value as a String
//def checkBoxVal = checkBox.getValue()

// Logic to do some actions depending on what check box value is selected
if (ITName == "Task") {
// define and set the required options when checkbox A is selected

//selectList.setFieldOptions(options.findAll {it.value in ['TST', 'TSTA',]});
def optionsMap = options.findAll {
it.value in ["TBD"] // list of options you want to show
}.collectEntries {
[
(it.optionId.toString()): it.value
]
}
field.setFieldOptions(optionsMap)

} else if (ITName == "Test Case") {
// define and set the required options when checkbox A is selected
def optionsMap = options.findAll {
it.value in ["Y","N"] // list of options you want to show
}.collectEntries {
[
(it.optionId.toString()): it.value
]
}
field.setFieldOptions(optionsMap)
}

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
mesher23
November 30, 2018

done, thanks

SMS
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 30, 2018

Hello there,

Please feel free to share with us your solution so that it can help other users in the future!

Regards,
Shannon

mesher23
December 2, 2018

general Kenobi!

TAGS
AUG Leaders

Atlassian Community Events