Conditions not working correctly on "Hide system or plugin UI element" Scriptrunner

Steven Mustari
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.
September 23, 2016

For some reason it seems that the conditional statements are not working correctly to hide UI elements. I love the features these fragments can provide but changes I make seem to always take place globally. currently I am using:

!jiraHelper.project?.key == "EDCO"

to try and have it show only projects other then issue key EDCO. I've tried both with and without the "not" in from of the statement and the results are always the same. Are there any examples of how to better utilize this? Another state ment I've tried that doesn't seem to work is:

issue.issueType == "Milestone"

Maybe there is some core thing I'm missing with conditional statements for use of these web fragments.

 

1 answer

1 accepted

3 votes
Answer accepted
adammarkham
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.
September 23, 2016

Your first condition should be:

jiraHelper.project?.key != "EDCO"

It will then show for all projects apart from the project with key EDCO

Similarly the second condition needs to be:

issue.issueType.name == "Milestone"

It will then show for only issues that are of type Milestone.

If the condition is true then the UI element will be displayed.

Steven Mustari
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.
September 24, 2016

Ah, so the first one is a syntax error.

The second one is because "issue.issueType" name is returning an object?

Perfect, Thank you for the help.

JamieA
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.
September 25, 2016

Steven - yes, you can find the javadoc at https://developer.atlassian.com/static/javadoc/jira/latest/reference/com/atlassian/jira/issue/issuetype/IssueType.html.

It's helpful to execute the conditions and "log.warn()" the return values, so you can see this.

For your first one you could have written :

! (jiraHelper.project?.key == "EDCO")

but the way Adam demonstrated is more usual.

 

 

Steven Mustari
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.
September 25, 2016

Thank you both Adam and Jamie. It turns out to be a simple question, but great customer service from Adaptavist as always.

JamieA
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.
September 25, 2016

You're welcome, and thank you for that.

Suggest an answer

Log in or Sign up to answer