Hi Team,
We are using JIRA DC, I am loking to hide a screen tab based on group.
Ex: I have View screen Tabs like 1,2,3,, when user in JSD group user can see all tabs in view screen. if user not in JSD group can see only 1,2 tabs.
I written code but I have not get it, can anyone help me on this.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def remoteUsersRoles = projectRoleManager.getProjectRoles(user, issueContext.projectObject)*.name
if ("jsd" in remoteUsersRoles) {
showTab(0);
showTab(1);
showTab(2);
}
else {
showTab(0);
showTab(1);
hideTab(2);
}
Hi Nagaraju,
For your requirement, you also need to invoke the GroupManager to verify if the user belongs to a particular group.
You could try something like this:-
import com.atlassian.jira.component.ComponentAccessor
def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def groupManager = ComponentAccessor.groupManager
hideTab(2)
if(groupManager.isUserInGroup(currentUser, "jira-servicedesk-users")) {
showTab(2)
}
Please note, this sample code is not 100% exact to your environment. Hence, you will need to make the required modifications.
Below is a print screen of the create screen for users in the jira-servicedesk-users group:-
And below is a print screen of the create screen for users who are not in the jira-servicedesk-users group:-
I hope this helps to answer your question :)
Kind Regards,
Ram
@Ram Kumar Aravindakshan _Adaptavist_ Thank you so much for your reply, yes this is working in only Create and edit screen only , but I need to hide this tab in view screen as well.
Can you see below screen shot, Tab2 hide in create screen but still I see in View ticket.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Nagaraju Reddy,
For your information, the Behaviour only works on the Create Issue, Update/Edit Issue, Assign Issue, and Workflow Transition screens and not on the View Issue Screen.
For more information on this, please visit the ScriptRunner documentation
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.