I am looking at options to ensure users cannot add components to issues in a jira project unless they are in a specific group. I know field security is not supported by Atlassian, but curious if anyone has utilized script runner to do this. I didnt know if anyone had been able to clear a field unless part of a group or something similar.
Users cannot add component (or the component is cleared during transition)
Users in specific group can add component (component is not cleared during transition)
Reading into this: https://community.atlassian.com/t5/Answers-Developer-Questions/Possibility-to-restrict-certain-Custom-Field-based-on-users/qaq-p/465663
But does not look like it will work on standard field like components.
I am on jira 7.x server. Thanks
Yes, ScriptRunner Behaviours can help you with that.
Here is a sample scriptrunner behavior script that will restrict the list to only show the top 3 components. Just add the logic to get the current user's group and map that against a pre-set list of allowed components
import com.atlassian.jira.component.ComponentAccessor
def fld = getFieldById('components')
def pcm = ComponentAccessor.projectComponentManager
def allComponents = pcm.findAllForProject(issueContext.projectId)
def firstThreeAsMap = allComponents.take(3).collectEntries{[(it.id):it.name]}
fld.setFieldOptions(components)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.