Hi,
How to hide a custom field based on user role or group in view screen only through script runner. Any possible solution will be helpful.
Thank you,
You can try this Script.
import com.atlassian.jira.component.ComponentAccessor
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def userGroups = ['group1', 'group2']
def userRoles = ['role1', 'role2']
def customField = getFieldByName('CustomFieldName')
def groupManager = ComponentAccessor.groupManager
def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
def currentIssue = underlyingIssue
def project = currentIssue?.projectObject
def isUserInRole = projectRoleManager.isUserInProjectRole(user, projectRoleManager.getProjectRole('role1'), project)
if (groupManager.isUserInGroup(user, 'group1') || isUserInRole) {
customField.setHidden(true)
} else {
customField.setHidden(false)
}
Hi @Ashok Shembde ,
Hope you are doing well.
As we are achieving based on the user role the Originator field should not be visible in view screen as we tried but i am unable to achieve. pasted the script below.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is something that can be achieved through Behaviors, although it is a seperate App on Cloud, it can be added to script runner (at no additional cost). I haven't tried this myself but the documentation shows you can show/hide fields on the issue view, take a look at the following links
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.