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?
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 :)
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.