Unable to disable issue screen tabs via Behaviours

Garry May December 12, 2018

Hi,

I'm attempting to write a simple Script Runner Behaviour to hide a specific tab (let's call it "details-tab") based on the issue type...with no success!

I did (unfortunately) manage to blow away the tab by calling tab.remove() in the final IF statement below - so I know the process to identify the tab works just not the disableTab or hideTab calls?

Any ideas what I'm missing ??

import com.atlassian.jira.issue.fields.screen.FieldScreenTab

def issuetype = underlyingIssue?.getIssueType().name

if (issuetype?.toLowerCase() == "document update") {
FieldScreenTab tab = getFieldScreen().tabs.find {
return (it.name.toLowerCase() == "details-tab")
}

if (tab) {
//hideTab(tab)
disableTab(tab)
}
}

 Thanks in advance

2 answers

1 accepted

0 votes
Answer accepted
Carmen Creswell [Adaptavist]
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.
December 13, 2018

Hi Garry! 

I believe that you are very close. I tested this code on a Behaviour on my instance and it works for me: 

def issueType = getIssueContext().getIssueType().getName()

FieldScreenTab tab = getFieldScreen().tabs.find {
return (it.name.toLowerCase() == "test")
}

if (issueType == "test") {
if (tab) {
hideTab(tab)
}
} else {
showTab(tab)
}

I used it in a Behaviour on the Issue Type field, but it would also work as an Initializer.

Garry May December 13, 2018

Thanks Carmel but still Nope - my Behaviour just doesn't work.  I've set it up as an Initialiser and also tried Adding a Field (i.e. the Issue type field) as you mentioned but still no change to the Jira Form (its tabs); I do get the correct logging being produced though.

I've even reduced my code down to the bare essentials:

  • The Mapping (Project and Issue Type) and
  • a simple Initialiser of
log.info("Disabling tab")
hideTab(2)
log.info("Tab Hidden")

Both messages appear in the log after refreshing the Browser but the number of tabs never changes? 

I've just updated the Script Runner plugin to v5.4.43 and no change...

Any ideas?

Carmen Creswell [Adaptavist]
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.
December 14, 2018

Hmmm. Sounds like something else is going on with this Behaviour. Do you have any other Behaviours (or Listeners, Post functions, etc) that could be acting on this tab or screen? 

0 votes
Garry May December 16, 2018

Hi Carmen,

I think you hit the nail on the head ...

I have 4 Behaviours setup but one of them did not have a Mapping (Project/Issue Type etc).   Once I set that all the Behaviours are now working !

A trap for young players no doubt :-)

Thanks for you help!!

Carmen Creswell [Adaptavist]
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.
December 17, 2018

Thanks Gary! If that answer helped you, could you please mark it as accepted so others can see this question was solved and it could possibly help them? Thanks! 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events