Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to make behaviours work on all create issue screens?

Elena Oleksenko
Contributor
July 1, 2020

Hello!

I configured the behaviours to restrict available issue types for users, depending on their project role, so that teammembers have ability to create all issue types, and non-teammembers - only one. 

Here is the script: 

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 ["Story"] })
}

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

if ("DCOPS Engineers" in remoteUsersRoles || "DCOPS AM" in remoteUsersRoles || "DCOPS Finance" in remoteUsersRoles || "DCOPS Leadership" in remoteUsersRoles || "DCOPS Onsite" in remoteUsersRoles || "DCOPS R&D" in remoteUsersRoles || "DCOPS Shift Leaders" in remoteUsersRoles) {
availableIssueTypes.addAll(allIssueTypes.findAll { it.name in ["Task", "Story", "Epic", "Maintenance", "Order", "Outage", "Sub-task", "Validation"] })
}

issueTypeField.setFieldOptions(availableIssueTypes)

 

It works fine on the usual create issue screen. But it does not work if you ckicking on Create while you on the project settings page (check the screenshot)

Is there a way to make behaviours works on this view as well? 

create2.png

1 answer

0 votes
Mathis Hellensberg
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 1, 2020

Hi @Elena Oleksenko 

It works fine for me, even on the project settings page. Try to remove all the if statements to verify whether it works without any of the role logic :)

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events