Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

Restricting Available Issue Types

I need to limit the creation of some issuetypes in a project and for users of a specific role.
I used this script but it still gives me an error.

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager

import static com.atlassian.jira.issue.IssueFieldConstants.ISSUE_TYPE

def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
def allIssueTypes = ComponentAccessor.constantsManager.allIssueTypeObjects

def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def issueTypeField = getFieldById(ISSUE_TYPE)

def remoteUsersRoles = projectRoleManager.getProjectRoles(user, issueContext.projectObject)*.name
def availableIssueTypes = []

if ("Users" in remoteUsersRoles) {
availableIssueTypes.addAll(allIssueTypes.findAll { it.name in ["Bug"] })
}

if ("Developers" in remoteUsersRoles) {
availableIssueTypes.addAll(allIssueTypes.findAll { it.name in ["Task"] })
}

issueTypeField.setFieldOptions(availableIssueTypes)

1 answer

0 votes
Payne Community Leader Apr 15, 2019

Your script works fine for me (tweaking the user roles and issue types to match my environment). What sort of error are you receiving?

Script.png

Errore script.jpg

The errors are of this type.
what should i change?

Antoine Berry Community Leader Apr 16, 2019

Hi Micaela, 

I think Issue_TYPE should be all capitals instead : ISSUE_TYPE. Otherwise just save the script as is, ignore the warnings/errors.

Antoine

Even putting all caps on does not work.
This is the error:

ERRORE SCRIPT 2.png

Antoine Berry Community Leader Apr 16, 2019

You are not supposed to run this script in script console, but instead create a behaviour linked to the "Issue Type" field.

Then it should work fine (because issueContext will exist at execution time).

Antoine

Ok, i'll try.

What should I change to be able to run the script only for a specific project?

Antoine Berry Community Leader Apr 16, 2019

Just configure the behaviour so it applies only to the specific project (Add Mapping). :)

Ok,

now i have this errore:

Error script 3.png

Antoine Berry Community Leader Apr 16, 2019

You are missing a "," between user and issueContext. Also as I said you need to create a behaviour (GG > Behaviours)

image.png

Thanks, it works now, but this solution does not work with jira JIRA Software 7.10.0 while it works with version 7.9.0.
Can anything be done?

Antoine Berry Community Leader Apr 17, 2019

This is beyond my knowledge, you would need to contact someone from adaptavist (raise a support ticket). 

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

☕️ Monday coffee with Jexo: Weekly Atlassian news roundup | 21st June 2021

Hi community 👋, as every Monday we're bringing you a quick update on what happened in the Atlassian ecosystem last week. There were a few interesting events like for example the announcement of th...

51 views 0 6
Read article

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