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?
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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. :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.