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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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

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.

Hello @John Chin

Perfect it works. 

Thank you so much. 

BR

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Jira Software

Presenting the "Best of 2020" Jira Software roundup!

Catch up with Atlassian Product Managers in our 2020 Demo Den round-up! From Advanced Roadmaps to Code in Jira to Next-Gen Workflows, check out the videos below to help up-level your work in the new ...

7,184 views 8 28
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you