Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Hide custom field based on Group

Musku Nagaraju
Contributor
June 11, 2019

Hi Team,

I am using Script runner for JIRA Server and I am looking to achieve Hide custom fields based on Group,

 

Ex: I have custom fields like Location, Instance , Min Cost, Max cost.... etc and I have one group like Generic Group.

I need to hide this fields to my Generic group.

 

Can you help me the right code.

 

Thanks

Nagaraju

 

 

1 answer

1 accepted

0 votes
Answer accepted
Antoine Berry
Community Champion
June 11, 2019

Hi @Musku Nagaraju ,

Please create a behaviour mapped to relevant issue type/project. Then create an initializer and use this script (update field id and name of group) : 

import com.atlassian.jira.component.ComponentAccessor

def groupManager = ComponentAccessor.getGroupManager()
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

if (currentUser != null && groupManager.getUsersInGroup("generic-group").contains(currentUser)) {
int customFieldId = 11000
def customField = getFieldById("customfield_" + customFieldId)
customField.setHidden(true)
}

Not sure if I understood well if generic group is a custom field though.

Antoine

Musku Nagaraju
Contributor
June 11, 2019

Hi @Antoine Berry 

Thanks for your inputs, however this is working for me in create and edit screen, but not in view screen.

I need to hide fields in view screen as well. 

Thanks

nagaraju

Antoine Berry
Community Champion
June 12, 2019

Unfortunately behaviours do not work on the view screen (as mentioned here). 

You might need javascript (example here - you will find other useful pieces of information).

Antoine

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events