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,557,694
Community Members
 
Community Events
184
Community Groups

Using Behaviour and Multielect customfield

Hello the community,

I have a little issue with behaviour with a multiselect customfield and I need your help.

To explain the case, When I create a ticket, I use a Multi select customfield and depending a value from the this cf, I need to show/required another customfield.

 

import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.issue.*
import com.atlassian.jira.issue.fields.screen.*
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.runner.util.UserMessageUtil


FormField QOPSubReason = getFieldById("customfield_17890")//QOP Sub-Reason
FormField Grades = getFieldById("customfield_10424")//Grades

if(getFieldById("customfield_17890").getValue().toString().contains("Isabel - 06-Allocation")){
Grades.setHidden(false)
Grades.setRequired(true)
}else{
Grades.setHidden(true)
Grades.setRequired(false)
}

 

But the behaviour does'nt work.

When I check selected value it appears as "NULL"

Image 1.png

I suppose I need to put a loop or something like this to get every time I change the value from the multiselect

Thank you in advance

 

1 answer

0 votes
Antoine Berry
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Apr 18, 2019

Hi @Cedric_DEVAUX ,

I tried this snippet and it works fine : 

def QOPSubReason = getFieldById("customfield_17890")
def Grades = getFieldById("customfield_10424")
def QOPSubReasonValue = QOPSubReason.getValue()

if (QOPSubReasonValue.find { it == "Isabel - 06-Allocation"}){
Grades.setHidden(false)
Grades.setRequired(true)
}
else {
Grades.setHidden(true)
Grades.setRequired(false)
}

Most importantly, map this behaviour to the "QOP Sub-Reason" field, so it listens to any update to it.

Regards,

Antoine

Hi @Antoine Berry 

This part works fine thank you! :)

... But I have another issue ...

Before this behaviour I have another behaviour to determine values of QOPSubreason from values of QOPReason.

Ex:

I select value 1 on QOP Reason, on QOP Sub Reason I will have values "Isabel - 06-Allocation", B, C

I select value 2 on QOP Reason, I will obtain on QOP Sub Reason no value

 

The problem is when I select by mistake value 1 on QOP Reason and value "Isabel - 06-Allocation" the QOP Sub Reason behaviour will activate Grades field but If just after I select value 2 on QOP Reason, the script keep the previous value of QOPSubreason and the field Grade stay visible whereas it must be hidden.

 

I hope my explanation is cleared ...

So my problem is to detect changes from QOP Reason into behaviour on QOPSubreason in order to reset QOPSubReasonValue.

 

Thank you

Antoine Berry
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Apr 24, 2019

Hi @Cedric_DEVAUX ,

I guess you can juste hide Grades field when QOP Reason does not allow "Isabel - 06-Allocation" on QOP Reason behaviour? i.e. something like 

if (!QOPSubReasonValue.find { it == "value 1"}){
Grades.setHidden(true)
Grades.setRequired(false)
}

Antoine

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events