Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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 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 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
Community showcase
Published in Marketplace Apps & Integrations

Staying organized with Jira: best practices for a better project management

Project managers know this problem: A “mountain of work” lays in front of you, and you don’t know how and where to tackle them. Different to-dos lie ahead, but just one task after the other can be ha...

231 views 2 1
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you