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

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 Jira

Admins, notify your Jira instance of system-wide changes with the new admin announcement banner

Hi All! We’re excited to share the launch of an announcement banner that lets Jira site administrators communicate directly to their users across their  Jira Cloud instance.  ...

693 views 17 19
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