Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

hide a tab from create screen doesn't work behaviours.

BYA January 20, 2021

Hello Community, 

I would like to hide the "bugdet info" tab(2) for people who don't have the administrators role. 

 I made this script , i put it in Initialiser function behaviours scriptrunner.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager
import com.onresolve.jira.groovy.user.FieldBehavioursdef

projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
def user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
def project = underlyingIssue.getProjectObject()
log.warn("project: "+ project)

//Get Current User
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
log.warn("currentUser: "+ currentUser)
def role = projectRoleManager.getProjectRole("Administrators")
log.warn("role: "+ role)
def roleproj = projectRoleManager.isUserInProjectRole(currentUser, role, project)
log.warn("roleproj: "+ roleproj)


if (projectRoleManager.isUserInProjectRole(currentUser, role, project)){
showTab(2)
log.warn("switchTab('Infos Budget'): "+ switchTab(2))
} else{
hideTab(2)
log.warn("hideTab('Infos Budget'): "+ switchTab(2))
//disableTab(1)
//switchTab(2)
}

 my problem this script work only in edit screen and not in create screen.

can you please correct this script community, i need your help. 

Thanks

BR

Fayçal

1 answer

1 accepted

0 votes
Answer accepted
John Chin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 20, 2021

Hi there,

Currently, I believe underlyingIssue is not able to capture the issue object on the create page as explained here. Try to use issueContext, for example:

def project = issueContext.getProjectObject()

 More example, take a look at this link.

BYA January 21, 2021

Hello @John Chin

Perfect it works. 

Thank you so much. 

BR

siva
Contributor
July 20, 2021

@John Chin 

Any behavior script to hide fields for specific users in view screen.

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Upcoming Jira Events