For a Custom Picker scripted field is there any way to access the issue
or project
context of the field, similar to the issue
which is available in a standard scripted field?
The following code (or similar for an issue parameter) works fine in isolation but I can’t get it “connected” to the issue/project in the field. I could, possibly, set the project key as a parameter, but was hoping to avoid it
/**
* Filter a given project's list of components by locating components with a given {prefix}
* @param descriptionPrefix The description prefix (inside the {})
* @param project A project object whose components will be filtered (defaults to the ST project if null)
* @return A filtered list of the project's components
*/
static def filterComponentsByProject(String descriptionPrefix, Project project) {
def projectManager = ComponentAccessor.getProjectManager()
def componentManager = ComponentAccessor.getProjectComponentManager()
project = project ?: projectManager.getProjectByCurrentKey("ST")
def components = componentManager.findAllForProject(project.id).findAll {
it.description?.startsWith("{${descriptionPrefix}}")
}
return components.collect {
[
value: it.id.toString(),
displayName: it.name
]
}
}