Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,552,471
Community Members
 
Community Events
184
Community Groups

Use ScriptRunner to modify a select custom field options depending on choice of other custom field

Edited

Is it possible to use a Scriptrunner customer field to modify the behaviour between two select list custom fields.

I would like to achieve something like the following:

Custom Field 1 value = 1

Custom Field 2 value dynamically populates options = A, B, C

Custom Field 1 value = 2

Custom Field 2 value dynamically populates options = D, E, F

I would like to avoid using a Cascading Select custom field, because you can't report off it as you can with an individual custom field.

Is this possible? I have tried to look at similar topics and have struggled to find something close to this.

Best wishes

Adam

 

Edit: On reading this advice, I have tried to do this using behaviours, but still no joy with the following script. It simply doesn't seem to change the view of options, no matter what I am selecting in the checkBox.

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()

// Point towards Change Result Reason custom field list
def selectList = getFieldById("customfield_15601")

// Point towards Change Result custom field list
def checkBox = getFieldById("customfield_15600")

// Get access to the required custom field and options managers
def customField = customFieldManager.getCustomFieldObject(selectList.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)

// 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 (checkBoxVal == "Successful") {
// define and set the required options when checkbox A is selected
def optionsMap = options.findAll {
it.value in ["Implemented Successfully"] // list of options you want to show
}.collectEntries {
[
(it.optionId.toString()): it.value
]
}
selectList.setFieldOptions(optionsMap)
} else if (checkBoxVal == "Partially Successful") {
// define and set the required options when checkbox A is selected
def optionsMap = options.findAll {
it.value in ["Bug", "Compatibility Issue", "Configuration Issue", "Deployment Failure", "Did Not Address Reason for Change", "Human Error", "Infrastructure Failure", "Incomplete CHG", "Incomplete documentation", "Management/Business Request", "Methodology not understood or tested", "Other", "Successful", "Testing Failure"] // list of options you want to show
}.collectEntries {
[
(it.optionId.toString()): it.value
]
}
selectList.setFieldOptions(optionsMap)
} else if (checkBoxVal == "Unsuccessful") {
// define and set the required options when checkbox A is selected
def optionsMap = options.findAll {
it.value in ["Bug", "Compatibility Issue", "Configuration Issue", "Deployment Failure", "Did Not Address Reason for Change", "Human Error", "Infrastructure Failure", "Incomplete CHG", "Incomplete documentation", "Management/Business Request", "Methodology not understood or tested", "Other", "Successful", "Testing Failure"] // list of options you want to show
}.collectEntries {
[
(it.optionId.toString()): it.value
]
}
selectList.setFieldOptions(optionsMap)
}

 

1 answer

1 accepted

2 votes
Answer accepted
Randy
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.
Apr 30, 2018

What type of reporting are you trying to do that you cant with the cascading select list custom field?  It might be easier to script against a cascading select than to re-invent it.

Thanks Randy, in the end I just got around it by using two separate select list custom fields.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events