Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,559,521
Community Members
 
Community Events
184
Community Groups

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 Leaders.
Jun 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?

3 answers

1 accepted

0 votes
Answer accepted
Ilya Turov
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.
Jun 20, 2019

try using jiraHelper.contextParams.issue.issueType.name instead

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 Leaders.
Jun 20, 2019

No love with that one either.

jiraHelper.contextParams.issue.issueType.name == "AWS Migration"

[Static type checking] - The variable [jiraHelper] is undeclared.
Ilya Turov
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.
Jun 20, 2019

did you actually try to save it and see if it works? because i tried logging it and it was fine. dont let simple type checking errors stop you.

i feel like even your original condition might be working. 

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 Leaders.
Jun 20, 2019

That's odd, I replied about an hour ago and it's not here.

At any rate, I enabled both fragments and I successfully hid the original Clone option, but the new "Clone to P_PRE" option is missing.

missingNewClone.jpg

Ilya Turov
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.
Jun 20, 2019

I think you are mistaking web section and web item

web section is basically what it is - a section (like how you see "create sub-task" button in your example is separated from top and bottom elements - that's because it'l located into it's personal section)

So I'd refer to examples here:

https://scriptrunner.adaptavist.com/5.5.0/jira/fragments/WebItem.html

Like Michael Thompson likes this
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 Leaders.
Jun 25, 2019

You're absolutely right, that is what I was doing wrong. I changed the fragment to a Web item and the "Clone to P_PRE" option appears in the drop down. Thanks Ilya!

I can't accept your reply as the answer, so I will accept the message thread. :)

0 votes
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jun 21, 2019

The web section is just a placeholder for the web items to go into.

So set your section to always be visible. It should only display when you have a visible web items in it.

And the web item has the issue as an available binding.

0 votes
Ilya Turov
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.
Jun 17, 2019

I guess different types of fragments have different types of Binding Variables.

What kind of fragment are you using in the second case? Also, there's a (?) question mark button in the bottom right corner which shows which variables you can use without declaring to help you.

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 Leaders.
Jun 20, 2019

Hi Ilya,

In the second case, I am using "Create a custom web section".

I did click on the question mark, but the resulting information wasn't particularly useful (see screenshot). Nothing clickable, just a vague commentary.

fragmentHelp.jpg

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events