Hi all,
After searching how I can restrict to single issue type, I came accross with a solution offered by Behaviours.
https://scriptrunner.adaptavist.com/6.9.1/jira/recipes/behaviours/restricting-issue-types.html
The problem I face;
The code snippet has no effect on my side. I use Scriptrunner 6.9.1. I added my group into a role i.e "Extern". This group is only available in "Users" role and "Extern" role. "Users" role has "Browse projects" and "Create Issues" permissions.
After adjusting the code snippet, the user is still able to see all issue types.
import com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.security.roles.ProjectRoleManager
import static com.atlassian.jira.issue.IssueFieldConstants.ISSUE_TYPE
def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def remoteUsersRoles = projectRoleManager.getProjectRoles(user, issueContext.projectObject)*.name
if (remoteUsersRoles == ["Extern"]) {
def constantsManager = ComponentAccessor.getConstantsManager()
def queryIssueType = constantsManager.getAllIssueTypeObjects().find { it.name == "Bug" }
getFieldById(ISSUE_TYPE).with {
setFormValue(queryIssueType.id)
setReadOnly(true)
}
}
Is there something wrong with the code snippet or what needs to changed in my case.
Any help much appreciated.
Hi @denizkaradal,
I don't find any issue with your snippet except IF condition you placed
your user is part of Extern and Users role but your script checks if users is JUST part of EXTERN role
the value of remoteUsersRoles is ["Extern", "Users"](If I'm not wrong)
you may want to try out the snippet by adjusting IF condition as below
if ("Extern" in remoteUsersRoles){
//code here
}
Hope this helps
BR,
Leo
Hi @Leo
It seems working but I got the following strange behaviour.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I would suggest you to map your behaviour script for Project field and your script as server side script
so that every time project field is changed the behaviour runs again which may fix your issue
BR,
Leo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@LeoI am not sure how it is done. I have already mapped it on a project and chose a issue type by using "Use project/issuetype mapping". Is there any more configuration? because I do not see any. Could you help me with it?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please check my screenshot but I do not see any options like you have. Is there due to version or do I miss something?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I see you've placed the script in initializer, if you notice the bottom of the screen shot, there is a field called "Add field". choose Project from there and once you added you'll find server-side script option
BR,
Leo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@LeoAnother try but no luck again. Here what I have done so far after your suggestion. In the "Mappings" section, the project was set along with "Bug" issue type(check pls my first picture). The group in which the users are has been also added into "Extern" and "Users" role.
1
2
What is the missing piece in here?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried but again no luck. I needed to select at least either "one issue type" or "all issue types". If not, I am not allowed to create a mapping. With"all issue types" did not function either.
In contrary, I realised that there is already a behaviour created for "Bug" issue type in this project but it only sets some text in "Description" by using "Initialiser".
What I have done: I deleted my behaviour and added my script as server side script into this existing behaviour but again no luck.
Any idea?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @denizkaradal ,
Did you try to match your behaviour with your workflow? Please select your related project workflow from the "Guide workflow" field
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.