Hi All
Warm Greetings!!
Is it possible to hide selected issue types from users unless they are in a specific group? We have a number of issue types that are for internal use only but users often mistakenly use them. We'd like to hide them from everyone but those in our team's group?
Eg:-
Project contains 3 issue types
Task
Bug
New Feature
Bug issue type should only be created by users in JIRA-Test group.
I tried simple script validator like
issue.projectObject.key ==
'ABCD'
&& isUserMemberOfRole(
'Administrators'
) && issue.issueTypeObject.name ==
'Bug'
but it won't be nice to tell the users that they are not allowed to create issue type after filling entire form.
I remember that @Jamie Echlin [Adaptavist] wrote the similar script to implement this but that script isn't there in https://scriptrunner.adaptavist.com or maybe I'm not looking at the correct page.
please suggest
Hi Rahul,
I have looked into this issue for you and unfortunately it is not possible to restrict the list of issue types using the Behaviours module of ScriptRunner out of the box. The closest you can do is to set just one issue type based on a users role or group as described in the documentation here.
However I have created a workaround for you which I have tested on my local JIRA 7.1.0 instance running ScriptRunner version 4.3.5.
The way the workaround works is by creating a new custom field of the Single Select List type called Issue Type Selection and adding the issue types that users not in the group can select.
You would then add a behaviour onto the new select field which makes the Issue Type field read only and the new select field mandatory if the user is not in the group and sets the issue type to the value of the Select List Field. Also if the user is a team member then it allows them to use the default Issue Type field and hides the new select field.
I have attached the script and config that is needed for this below. Note - I have used the jira-software-users group as my example admin group but you will need to replace this with the name of the group inside your instance.
Code:
import com.atlassian.jira.component.ComponentAccessor import static com.atlassian.jira.issue.IssueFieldConstants.ISSUE_TYPE def issueType = getFieldById(ISSUE_TYPE) def issueTypeSelect = getFieldByName("Issue Type Selection") // Get the issueTypeSelect Value as a String def issueTypeSelectVal = issueTypeSelect.getValue().toString() // Get a pointer to the current logged in user def userUtil = ComponentAccessor.getUserUtil() def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() // If user is not in admin group then make the field read only if (!userUtil.getGroupNamesForUser(currentUser.name).contains("jira-software-users")) { issueType.setReadOnly(true) issueTypeSelect.setRequired(true) // Set the Issue Type to the Select List Value issueType.setFormValue(issueTypeSelectVal) // If the user is and admin then they may use the standard Issue Type field } else if (userUtil.getGroupNamesForUser(currentUser.name).contains("jira-software-users")) { issueType.setReadOnly(false) issueTypeSelect.setRequired(false) //Also Hide the Field as the admin does not need it issueTypeSelect.setHidden(true) }
Config:
Screen Shot 2016-10-05 at 16.44.26.png
I hope this helps.
Thanks
Kristian
@Jamie Echlin [Adaptavist]
Could you point me to the script or give some insights on this.
thanks in advance.
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.