Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Field behaviour not working

Stephen Marsh March 1, 2019

Hi,

I want to configure a behaviour on the resolution field that makes another field (ListTest) visible and required when the resolution of 'Rejected' is chosen. Here is my script that is currently not hiding the field nor making it required.

Please see script below and I have also attached the behaviour confg i am using...

import com.atlassian.jira.issue.resolution.Resolution

def resolutionField = getFieldById("resolution")
def listField = getFieldById("ListTest")

def resolution = resolutionField.getValue() as Resolution

if (resolution.name == "Rejected") {
listField.setRequired(true)
listField.setHidden(false)
} else {
listField.setRequired(false)
listField.setHidden(true)
}

Can anyone suggest what I am missing? Thanksreject.jpg

2 answers

1 accepted

0 votes
Answer accepted
Carmen Creswell [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 1, 2019

Hi Stephen, 

I haven't tested your code in my own instance, but just by looking at it, I believe that you might need to change the line: 

def listField = getFieldById("ListTest")

to this: 

def listField = getFieldByName("ListTest")

Again, I haven't tested it in my instance, but I believe that "ListTest" is a custom field name. System fields are gotten by their ID like you have in the line above, but to use the name of a custom field, you'll need to change the way you get it!  

0 votes
Stephen Marsh March 4, 2019

Thanks cant believe I hadn't spotted that :-)

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, mindful member, mindful member badge, atlassian community, community kudos, community giveaway, atlassian swag, community values, empathy and kindness, badge challenge, atlassian learning, community engagement, swag giveaway

Earn a Badge, Win a Prize 🎁

Earning the Mindful Member badge proves you know how to lead with kindness, plus it enters you into a giveaway for exclusive Atlassian swag. Take the quiz, grab the badge, and comment on our announcement article to spread the good vibes!

Start here
AUG Leaders

Atlassian Community Events