Hello,
Is there a way to make custom field called " ECC Reason" required if the Label is selected as " Emergency" ?
If this can only be done by a script runner , do you have any samples?
Thank you.
We use JIRA 7.5.0
Elif
Hi Elif,
There are a few examples in the Community, here is one:
https://community.atlassian.com/t5/Jira-questions/Required-field-and-condition/qaq-p/752807
Hope this helps,
-Scott
Scriptrunner behaviours:
def dropDown = getFieldByName("Liste1")def hiddenField = getFieldByName("Liste2")log.debug("dropdown value" + dropDown.getValue())
hiddenField.setRequired(false)if (dropDown.getValue() == "aa") { hiddenField.setRequired(true)}
@David STOCKY,
Here is what I am trying to do. If Jira user states " Labels= EmergencyChange", then the custom field " ECC Justification" is required.
I tried the script you have provided but nothing happens. What am I doing wrong? Thanks!
Here it is;
You are running a script on ECC Justification.
Or you want to have a special behaviours on the change on the fields "Labels".
So you have to move your script from ECC Justification (Fields) to Labels (Fields) on your script attached.
Do you get the point?
You script should be launch on Labels's event
Here what I have tried no change
Hello @Elif Alverson
If your quiestion actual.
Yes, as David say, you need behaviour mapped to the labels field.
But labels field is special one. When there is only one label it is String object, but if there two or more its List<String> object, so keep it in mind, we can make script like this:
def labels = getFieldById(getFieldChanged())def targetField = getFieldByName("ECC Justification")targetField.setRequired(false)if ("EmergencyChange".equals(labels.getValue()) || labels.getValue().find {it == "EmergencyChange"} ){ targetField.setRequired(true)}
I check it on ScriptRunner v5.4.7, it works! Hope it help you!
@Mark Markov,
Thank you for your response. It works on transition step " Submit for Approval".
We need " ECC Justification" to be required only for transition " Resolved".
I put the conditions however it does not work.
Any ideas?
You can use method getActionName() to find current transition, see code bellow
if ("Resolved".equals(getActionName())) {def labels = getFieldById(getFieldChanged())def targetField = getFieldByName("ECC Justification") targetField.setRequired(false)if ("EmergencyChange".equals(labels.getValue()) || labels.getValue().find { it == "EmergencyChange" }) { targetField.setRequired(true) }}
@Mark Markov, I have tried however it does not work. I can resolve issues with EmergencyChange labels without filling " ECC Justification" custom field.
Any idea why?
It looks like you're new here. Sign in or register to get started.