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"
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
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.