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
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
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
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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.