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,551,772
Community Members
 
Community Events
184
Community Groups

Displaying a field based on another field selection

Hi,

I am hoping to implement the following, if possible.

Custom Fields to be created:

A - Test
a.1. E
a.2. R
a,3. T

B - Test 1
b.1. J
b.2. K
b.3. L

C- Test 2
c.1. I
c.2. O
c.3. P

Only A & B are compulsory when creating a ticket
But when a.1 and b.3. is selected then A, B and C are compulsory

 

Not too sure how this would be implemented but I suspect a specific code for this, but that is a bit beyond my capability.

 

Thanks! 

1 answer

1 accepted

1 vote
Answer accepted
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Mar 18, 2021

Hi there

Taking you at your word that you want field C to be required when a.1 is selected and at the same time b.3 is selected, you could try a script like this:

def fieldA = getFieldByName('A - Test') //this is the label for the field A
def fieldB = getFieldByName('B - Test 1')
def fieldC = getFieldByName('C - Test 2')

def fieldAValuesThatTriggerFieldCRequired = ['a.1. E'] //this has to be the label of the option
def fieldBValuesThatTriggerFieldCRequired = [ 'b.3. L'] //you could add additionoal values here in coma separated list
def valueA = fieldA.value
def valueB = fieldB.value

def fieldCIsRequired = valueA in fieldAValuesThatTriggerFieldCRequired && valueB in fieldBValuesThatTriggerFieldCRequired
fieldC.setRequired(fieldCIsRequired)

You would put this code in the behaviours section of script runner. Create a new configuration that maps to your project. Then edit the behaviour configuration and add field A and Field b.

For each of those 2 fields, add a server-side script and put the script above in each of those server-side scripts. These server-side scripts run each time values change in each of those fields so that the fieldC can be re-evaluated each time.

To make fieds A and B required, you can do it with the behaviour toggles on each field. Or you can make this globally required in your project's field configurations.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events