Only allow a certain group access to a tab and its contents on all screens

Lara Arthur November 23, 2020

Hello Atlassian community,

I have a project where we've got a 'QA Notes' tab on our Findings issue type screen. This tab has a QA Notes field on it where our QA group would like to add notes, but only have people in the QM group have access to edit and see those notes/tab.

Here's what I've added via the ScriptRunner Behaviours:

Mappings are to the project and specific issue type.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue

def groupManager = ComponentAccessor.getGroupManager()

if ('isUserinGroup QM' == 'false') {
hideTab(2)
}

I've tried it with and with/out the import/def ...and I've found that if I just use 

if ('isUserinGroup QM') {
hideTab(2)
}

...the tab is hidden, but it's hidden to even the QM group. I don't know what I'm doing wrong here...any help is greatly appreciated.

2 answers

1 accepted

0 votes
Answer accepted
Daniel Ebers
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.
November 28, 2020

Hi Lara,

the function hideTab(2) is working as per your description and per my past experience.

I am unsure about your implementation of testing for the group, though.

I remember that it worked like this but please double check and verify:

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getUser()

if (! userUtil.getGroupNamesForUser(currentUser.name).contains("QM")) {

// the rest of existing code goes here

}

Please do not forget the closing curly bracket at the very end.

Hope it helps!

Cheers,
Daniel

Lara Arthur November 30, 2020

@Daniel Ebers Thanks for the script...I updated with a couple items. It is technically working, but only on the Edit screen. If you aren't part of the QM group you can still View the 'QA Notes' Tab. What do I need to add to hide the tab from the View screen as well? Or is this not possible since I've created a Behaviour?

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.util.UserUtil

def userUtil = ComponentAccessor.getComponent(UserUtil.class)
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()


if (! userUtil.getGroupNamesForUser(currentUser.name).contains("QM")){
hideTab(2)
}

 

The only workaround I've found for this is to take the 'QA Notes' field off of the 'QA Tab' View screen...but the QM group wants to be able to view the contents on the View screen and not have to click on Edit to view the fields contents...so this won't work.

Daniel Ebers
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.
November 30, 2020

For the view screen it is not possible as per documentation. This is a restriction due to architectural circumstances.

Lara Arthur November 30, 2020

That's what I thought you might say! Uggghhh.

Thanks for the reply.

0 votes
Lara Arthur December 1, 2020

For anyone who may be interested in doing this, I did double check with ScriptRunner and they confirmed that my ask is not possible at this time. They do have a new Feature request documented - Make hideTab work on View screen SRJIRA-3125. This is in a TO DO status.

Suggest an answer

Log in or Sign up to answer