make field mandatory for a particular issueType

I expected this code to make the field mandatory for "Issue Type" = QA or when "Task Type" field is "analysis" or Code Review" for rest of issue types.

 

Its is working for the change in "Task Type" field values, but not working for "Issue Type" = "QA"

What am I doing wrong?

 

 

def selectCFValue = getFieldByName("Task Type").getValue()
def targetField = getFieldByName("SVN Path")
def issueType = getFieldByName("issuetype-field").getValue()
if (issueType == "QA")
targetField.setRequired(true)
else
if (selectCFValue == "Analysis" || selectCFValue == "Code Review")
    targetField.setRequired(true)
else
    targetField.setRequired(false)

2 answers

0 votes

Issue type is not a field (so line 3 is wrong) and when you fetch the object, a simple comparison to a string is never going to work.

Try

if ( "QA".equals (issue.getIssueTypeObject.getName()) )

instead

0 votes
Joe Pitt Community Champion Jul 05, 2017

Why not use a field configuration for that issue type and make it mandatory there? that is built in and no code is required.

Ok, so you are suggseting making a duplicate field configuration for QA task as its now using a shared configuration with other issue tupes that do not need this field as required?

I guess I can do that

Joe Pitt Community Champion Jul 05, 2017

Yes. That is the beauty of the field configuration scheme. You can create different field configurations for each issue type if desired and create the field configuration scheme from them. It is th configuration scheme, not an individual configuration that is tied to the project. 

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,932 views 12 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot