Groovy expresion for issue types

Mihai Schwarz
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.
July 28, 2017

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

3 votes
Answer accepted
Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 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. 

Mihai Schwarz
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.
July 28, 2017

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 Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 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 Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 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 

Mihai Schwarz
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.
July 28, 2017

@Tarun Saprait worked,  thanks!

J Manas Kumar December 23, 2019

Hi @Tarun Sapra   how can we import Issue Type in Behaviors, Because when i am trying to use IssueType Object in Behaviors, its unable to import even if i have added import com.atlassian.jira.issue.IssueType; on top of my class. Can you suggest anything?

Suggest an answer

Log in or Sign up to answer