Hello,
I am using behaviors to hide specific issuetypes, i did the configuration (added a server side script to issuetype field in scriptrunner/behaviors) 1 week ago, it was working fine but now it doesnt work.
What could be the reason?
I tried this script as well but it is switching it back to the ones that specified rather than hiding it.
Jira Data Center v9.12.7
Based on what condition do you intend to hide the Issue Type? Is it based on the User's Group or Role?
I have provided a solution for the former in this Community Post.
I'm looking forward to your feedback and clarification.
Thank you and Kind regards,
Ram
Hi @Ram Kumar Aravindakshan _Adaptavist_ ,
Thank you for your help.
I don't have a condition. I have several issuetypes in my scheme and i want to hide some of them so that the other projects using the same scheme wont be affected. I also did the project mapping in the behavior.
import com.atlassian.jira.component.ComponentAccessor
def issueTypeField = getFieldById("issuetype")
def hiddenIssueTypes = [
"Analysis", "Epic"
]
def issueTypes = ComponentAccessor.getConstantsManager().getAllIssueTypeObjects()
def visibleIssueTypes = issueTypes.findAll { it.name !in hiddenIssueTypes }
issueTypeField.setFieldOptions(visibleIssueTypes.collectEntries { [(it.id): it.name] })
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please share a screenshot of your Behaviour configuration. I need this to check how you are associating your Behaviour configuration with the Projects and rerun the test in my environment.
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Büşra Saltık ,
Welcome to the community !!
You have shared the link for plugin version 6.33.0. Script runner 6.33.0 is not compatible with Jira datacenter 9.12.7.
Script runner 8.22.0 and above is only compatible with Jira 9.12.17.
As you said, "1 week ago, it was working fine", was there any upgrades to plugin or Jira version in recent days ?
You can find the updated way to restrict Issue type here for the latest plugin version: https://docs.adaptavist.com/sr4js/9.6.0/features/behaviours/behaviours-examples/restricting-issue-types
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for your reply.
We are using Scriptrunner version 8.30.0
We renew the service management licence yesterday. Could that be the reason? All the other behaviors are working fine, only the one for issuetype field is not working.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Büşra Saltık
Did you check the license for plugin ? Is it expired or not. Same number of user license as JSM ?
Meantime try to recreate it using the steps given in https://docs.adaptavist.com/sr4js/8.30.0/features/behaviours/behaviours-examples/restricting-issue-types
I suggest first you try in Test environment. If test environment does not exist, try only for test project.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Everything is valid. When i apply the script given in the link;
When I select the issue type that should be hidden, it converts it into a visible issue type and allows me to select it, but it doesn't hide the other options
Thank you for your help!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you please share your script here.
Also please check for roles mentioned in the script. Are you part of it not, if the roles are available in your project or not etc.
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.
Hi @Büşra Saltık ,
Go to Script runner --> Behaviors --> Create Behavior --> Give a name and click on Create Mapping
Here select Project name and All issue types.
Scroll down and add below script (modify the Issue type names and Roles as per your project and based on who should see what issue types)
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 user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
def issueTypeField = getFieldById(ISSUE_TYPE)
def userRoles = projectRoleManager.getProjectRoles(user, issueContext.projectObject)*.name
def availableIssueTypes = []
//allow only users in 'Administrators' project role to get Query and 'General Request' issue types as dropdown
if ("Administrators" in userRoles) {
availableIssueTypes.addAll(["Query", "General Request"])
}
//allow only users in 'Developers' project role to get "Task" issue types as dropdown
if ("Developers" in userRoles) {
availableIssueTypes.addAll(["Task"])
}
issueTypeField.setFieldOptions(availableIssueTypes)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, i applied this one but still
When I select the issue type that should be hidden, it converts it into a visible issue type and allows me to select it, but it doesn't hide the other options.
I believe there is another issue
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Ram Kumar Aravindakshan _Adaptavist_ is from Script runner plugin team. He can surely help/guide you here better.
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.