I have been working to find a solution to support the following scenario and need some help.
We have a project that our management uses to track project funding sources. These funding sources are tied to specific projects and releases in Jira. Now, they want to have that project funding code automatically populated within the issues of the target projects.
Now, I've looked at the main project and see some issues, so I am adding a project picker field ("Project Name") and a multi-select drop down ("Project Version") so that the management team can better track their data.
1st, what I want to do is to have the project picker field display only the version of the selected project so that the user only sees the projects versions in the drop down list. To help, I pulled all projects and versions from the jira db and used the scriptrunner Built-In script to populate the 2 fields (Project Name and Project Version). I've also taken the All Previous Versions script from the documentation and modified it a little to get the versions of a project using an issue key for testing and I at least get the right results.
package com.onresolve.jira.groovy.test.scriptfields.scripts
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.comparator.VersionComparator
def issueManager = ComponentAccessor.getIssueManager()
def issue = issueManager.getIssueObject("WSC-80")
def versionManager = ComponentAccessor.getVersionManager()
def versions = versionManager.getVersions(issue.projectObject)
def comparator = new VersionComparator()
def lowestFixVersion = issue.fixVersions.min(comparator)
def returnedVersions = versions.findAll{
comparator.compare(it, lowestFixVersion) < 0
}
log.debug("All prior versions: ${returnedVersions}")
return (lowestFixVersion ? returnedVersions : null)
return versions
Now, I'd like to somehow use the above script to take the project selected in the project picker field to generate the results and then use a behavior to only show those options in the project version field.
Any help is greatly appreciated.