Hello!
I'm trying to implement a Behavior using Scriptrunner. I have a field for Severity that is required on a specific Service Desk request. Desired behavior is that if a user selects "High" value for Severity, a field (previously hidden) will appear for Emergency Justification, and this field will be required.
I modeled my code after the solution I found on this question, but it isn't working. Here's the code:
import com.atlassian.jira.issue.fields.CustomField
def CustomField = getFieldById("customfield_10408")
def Custom2Field = getFieldById("customfield_10622")
if (CustomField.getValue() == "High (Emergency)") {
Custom2Field.setRequired(true)
Custom2Field.setHidden(false)
}
else {
Custom2Field.setRequired(false)
Custom2Field.setHidden(true)
}
It appears to work partially, because customfield_10622 is set in the screen as not hidden, and it is hidden to the user when initially entering the Request. But it doesn't appear when the defined value is selected. What am I missing?
*using Jira 8.1 + Scriptrunner 5.5.6.1-jira8
Can you paste a screenshot of behaviours configuration?
In my cases when behaviours didn't work the reason was in wrong place where I put script.
Regards,
Seba
Hi Seba,
Thanks for the reply. You may be right - the screenshots I used from the how-tos were for an older version and didn't look like my version, so maybe I put it in the wrong place. See screenshot.
Thanks,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry @Sebastian Krzewiński I tried to respond yesterday and the community seemed to be down. Adaptavist support got back to me and indeed, I was using the wrong area for my script (entering it in the Initializer area, not the server-side script area). All good now!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Bethany Glismann ,
What do the logs say ? You should log the value to make sure it is consistent to the String you are testing against :
log.error("CustomField value : " + CustomField.getValue())
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.