You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
Creating a Jira screen for new users requests. I need to create a field that is multi-picker that lists the current Jira projects, so the person requesting the account can pick which projects they need access to, and populate the ticket accordingly.
I am certainly not a programmer and I can't find anything out there like this.
Any help appreciated
Thanks,
Matt
You can create a scriptrunner script field using the "Custom Picker" option.
Using the "Show Snippet", I grabbed the example for Version picker, and converted the suggested configuration code to make it work as a project picker:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.project.Project
import com.onresolve.scriptrunner.canned.jira.fields.model.PickerOption
import org.apache.commons.lang3.StringUtils
def projectManager = ComponentAccessor.projectManager
validate = { Project project ->
!project.archived
}
search = { String inputValue ->
projectManager.projectObjects.findAll {
!it.archived && (StringUtils.containsIgnoreCase(it.name, inputValue) | StringUtils.containsIgnoreCase(it.key, inputValue))
}
}
getItemFromId = { String id ->
projectManager.getProjectObj(id.toLong())
}
toOption = { Project project, Closure highlight ->
new PickerOption(
value: project.id.toString(),
label: "$project.name ($project.key)",
html: "${highlight(project.name, false)} (${project.key}) ${getLozenge(project)}",
)
}
renderItemViewHtml = { Project project ->
"$project.name ($project.key) ${getLozenge(project)}"
}
renderItemTextOnlyValue = { Project project ->
"$project.name ($project.key)"
}
String getLozenge(Project project) {
if (project.isArchived()) {
'<span class="aui-lozenge aui-lozenge-subtle">Archived</span>'
} else {
'<span class="aui-lozenge aui-lozenge-current aui-lozenge-subtle">Active</span>'
}
}
You can find more details in the documentation: https://docs.adaptavist.com/sr4js/6.58.1/features/script-fields/built-in-script-fields/custom-picker?utm_source=product-help
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for this, Peter. Do you know of any concise documentation that clearly communicates the functions that are expected to be implemented in a configuration script?
The ? button for the configuration screen shows that the following are accessible, but it is not clear which may be required for an implementation
log |
multiValueDelimiter |
allowJavaScript |
maxRecordsForSearch |
highlightMatchesWordPrefixesOnly |
disableTextIndexing |
getPlaceholderString |
renderViewHtml |
renderColumnHtml |
renderTextOnlyValue |
search |
validate |
getItemFromId |
toOption |
renderItemViewHtml |
renderItemColumnViewHtml |
renderItemTextOnlyValue |
Notably absent is `issue` which is available in a simple scripted field.
My use case is to access (a subset of) Components in the current project, which would be doable if I could find a way to refer to the current issue/project/component list
I find the Adaptivist documentation to be frantically dispersed...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm not aware of any documentation other than the page I shared above.
But based on that, the "issue" variable is only defined in the context of the search method you see in the '?' popup.
So if you want to get a filtered subset of components, you can set the configuration script to:
search = {String inputValue, Issue issue->
def projectComponents = ComponentAccessor.projectComponentManager.findAllForProject(issue.project.id)
return projectComponents.findAll{ <filter criteria for your subset>}
}
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.