You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hi,
Here is my scenario:
1). Let's say I have a custom checkbox field with options 1,2,3,4,5,6,7,8,9,10.
2). Initially, I only want options 1,2,3,4,5 visible to the user, and 6-10 hidden. Options 1-5 should always be visible.
3). If the user checks option1, then make 6,7,8 also visible. If the user checks options2, make 9,10 visible.
4). If the user unchecks 1, then 6,7,8 are hidden again. If the user unchecks 2, then 9,10 are hidden again.
Is this possible do to within a single custom field? Is there a behavior for this? I have not seem an example of this so far. Has anyone else?
Here is how I would implement this using behaviours.
You will need to create a server-side initializer script, and a server-side script for your checkbox field.
Place this code in both script boxes (adjust for field name and actual option values):
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.customFieldManager
def optionsManager = ComponentAccessor.optionsManager
def chkField = getFieldByName('checkbox1')
def initalOptions = ['1','2','3','4','5']
def conditionalOptionMap = [
'1':['6','7','8'],
'2':['9','10']
]
def chkCf = customFieldManager.getCustomFieldObject(chkField.fieldId)
def chkConfig = chkCf.getRelevantConfig(issueContext)
def chkOptions = optionsManager.getOptions(chkConfig)
def selectedOptions = chkField.value
//turn single value string into an array of 1
if(selectedOptions instanceof String) selectedOptions = [selectedOptions]
def showOptions = chkOptions.findAll{opt->
opt.value in initalOptions ||
selectedOptions.any{
opt.value in conditionalOptionMap[it]
}
}
chkField.setFieldOptions(showOptions)
The initialiser will run when you first open the create (or edit) screen. The field script will run every time you check/uncheck any of box.