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,
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
Hi @N Sreenivasulu Reddy ,
You can try this Script.
import com.atlassian.jira.component.ComponentAccessordef user = ComponentAccessor.jiraAuthenticationContext.loggedInUserdef userGroups = ['group1', 'group2'] def userRoles = ['role1', 'role2'] def customField = getFieldByName('CustomFieldName')def groupManager = ComponentAccessor.groupManagerdef projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)def currentIssue = underlyingIssuedef project = currentIssue?.projectObjectdef 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.
It looks like you're new here. Sign in or register to get started.