Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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

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

No love with that one either.

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

[Static type checking] - The variable [jiraHelper] is undeclared.

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. 

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

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

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. :)

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.

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

0 votes

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.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

75 views 0 4
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you