Groovy expresion for issue types

Hi guys,

I am looking to add a set field value to constant or groovy expression post function which will check if the issue type = X and if the condition is true then a certain field gets populated.

I tried with the groovy expressions issue.getIssueTypeObject.name == "X" and issue.issueType.name=="X".  Do you have any idea why isn't working?

I am using JIRA 7.2.6

Thanks!

1 answer

1 accepted

1 vote
Tarun Sapra Community Champion Jul 28, 2017

This should work-

if(issue.issueType.name == 'Bug'){
//here you can add code to populate the field

}

 Which version of script runner plugin do you have installed, as this condition is very basic should work very easily. 

Hi Tarun,

Thanks for replying.

The post function looks something like this

Capture.PNG

I tried multiple approaches but nothing seems to work. Script Runner is version 4.3.12.

Thanks!

 

Tarun Sapra Community Champion Jul 28, 2017

I thought you are using script runner plugin thus I shared the groovy script with you, but it seems you are using JMWE plugin which also supports groovy script (new feature in the plugin)

 

Please use this syntax


return (issue.get("issuetype").getName() == "Bug")

  

Tarun Sapra Community Champion Jul 28, 2017

Please see the docs here in case you are using groovy expressions for the JMWE plugin -https://innovalog.atlassian.net/wiki/display/JMWE/Groovy+editor+in+JMWE 

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Monday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

685 views 6 13
Read article

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