Hi,
I wish to make a field on JIRA create screen mandatory based on the selection of another select list field.
I have tried below two solutions:
def childField = getFieldByName("US Market Access")
def parentField = getFieldById(getFieldChanged())
def selectedOption = parentField.getValue() as String
if ((selectedOption == "Yes") || (selectedOption == "No"))
{
childField.setRequired(true)
}
else
{
childField.setRequired(false)
}
OR
FormField priField = getFieldById("16020")
FormField priJustField = getFieldById("15820")
String Criticality = (String) priField.getFormValue()
if (Criticality == "18170") { // 11306 is Blocker
priJustField.setRequired(false)
}
else{
priJustField.setRequired(true)
}
But both of them are making field mandatory, even if i dont select value of parent field.
i TRIED "script runner" validator on create transition also "Has custom field value equal to "
that also made the same issue.
Can you please suggest the script to use?
refrence help:
Nidhi
Hi Nidhi,
If you want a behaviour try the following
def selectCFValue = getFieldByName("Single Select List CF").getValue() def targetField = getFieldByName("US Market Access") if (selectCFValue == "OptionA" || selectCFValue == "OptionB") targetField.setRequired(true) else targetField.setRequired(false)
regards
Thanos
Hi,
Thanks for that,
When I try it in the create transition of the workflow, its showing Field mandatory error even if I do not select any value in source instance:
def selectCFValue = getFieldByName("Impact Transaction Reporting").getValue()
def targetField = getFieldByName("US Market Access")
if (selectCFValue == "Yes" || selectCFValue == "No")
targetField.setRequired(true)
else
targetField.setRequired(false)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi nidhi
I am a bit confused. Do you want a validator or a behaviour (the example above is a behaviour) ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi -Thanos Batagiannis I also have a question regarding this issue-
field A is a select list- single choice.
I want to create a configuration on the "create" screen-
if field A='x' --> I want to make field B mandatory.
Can you help me please?
Thanks!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi All,
The behavior script posted above:
def selectCFValue = getFieldByName("Single Select List CF").getValue() def targetField = getFieldByName("US Market Access") if (selectCFValue == "OptionA" || selectCFValue == "OptionB") targetField.setRequired(true) else targetField.setRequired(false)
It works witch select lists. However if the source field is Tempo account filed it does not recognize neither the value or the ID of the account. Do you know the correct method to get the value for Tempo account Field?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Nadica Gaber ,
I used your code on behaviour to the same issue.
I would like to make 'environment platform' field (Text Field type) a mandatory field, only if 'Patch type' field (Select List (single choice) type) = 'X'.
There is something I should choose or select in the behaviour settings? cause it didn't work for me..
This is my code:
def selectCFValue = getFieldByName("Patch Type")
def targetField = getFieldByName("Environment/ Platform")
if (selectCFValue.getValue() == "GA Point Patch" || selectCFValue.getValue() == "GA Cumulative Patch")
targetField.setRequired(true)
else
targetField.setRequired(false)
and attached the behaviour screen:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Dan27,
You are missing getting of the value from Patch Type field.
Add getValue():
def selectCFValue = getFieldByName("Patch Type").getValue()
Regards,
Nadica
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Nadica Gaber ,
Still not working...
my new code:
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
def regressionIssueField = getFieldById(getFieldChanged())
def targetField = getFieldByName("Environment/ Platform")
def selectCFValue = getFieldByName("Patch Type").getValue();
if (selectCFValue == "GA Point Patch" || selectCFValue == "GA Cumulative Patch") {
targetField.setRequired(true)
} else {
targetField.setRequired(false)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.