Forums

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

Scriptrunner: Add a Condition to a Web Section Limiting Issue Type

Michael Thompson
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 Champions.
June 17, 2019

Having some trouble with Script Fragments in Jira Software 8.1.0. and Adaptavist ScriptRunner 5.5.6.1-jira8.

GOAL

One of my projects contains a unique Issue Type called AWS Migrations. We create a parent issue and six sub-tasks underneath it for each software environment (QA, Pre-Prod, Practice, Production, and Demo).

I want to replace the Clone button with multiple scripts to Clone to P_PRE, Clone to P_PS, Clone to P_PRD, and Clone to P_DEM. This will allow me to create a custom clone script that also edits certain values in the master ticket that are important for each environment.

PROBLEM

My first script fragment should hide the Clone option from the More dropdown, but only if the Issue Type is AWS Migrations. I added the following condition and it works fine.

! (issue.issueType.name == "AWS Migration")

My next script fragment is to add a new option Clone to P_PRE to the More dropdown. Since this should only be available if Issue Type is AWS Migrations, I figured this should work.

issue.issueType.name == "AWS Migration"

Instead, I get the following checking error:

[Static type checking] - The variable [issue] is undeclared.
@ line 1, column 1.

QUESTION

Why is this happening? What is the correct syntax for the condition?

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
aleksnako
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 25, 2020

Hi @Alexander Raymukanov 

I looked into that class methods and I found that you cant get the issue itself, instead you can retrieve its id. Check the code below:

IssueManager issueManager = ComponentAccessor.getIssueManager()

MutableIssue issue = issueManager.getIssueObject(event.getIssueId())

Hope you find it usefull. 

Alexander Raymukanov
Contributor
September 26, 2020

Hi @aleksnako .

thanks for information.

can you point me on class documentation? 

Regards,

Alexander

TAGS
AUG Leaders

Atlassian Community Events