Hi Folks!
When creating an issue we need that version type customfield "Found in versions" was prepopulated with first (earliest) unreleased version.
For example we have:
22.3 - unreleased
22.2 - unreleased
22.1 - unreleased
21.12 - released
21.11 - released
On the creation screen we need "22.1" in the field as prepopulated.
I set the following behavior, that works:
def foundinversionField = getFieldByName("Found in Version")
foundinversionField.setFormValue("22.1")Also I can get last version in Console
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.CustomFieldManager
def issueManager = ComponentAccessor.issueManager // console Only
def issueKey = "KEY-74633" // console only
def issue = ComponentAccessor.issueManager.getIssueByCurrentKey(issueKey) // console only
def foundinversionField = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Found in Version")
def value = issue.getCustomFieldValue(foundinversionField)
def versionManager = ComponentAccessor.getVersionManager()
def projectManager = ComponentAccessor.getProjectManager()
def project = projectManager.getProjectObjByKey(issue.projectObject.key)
def versions = versionManager.getVersions(project)
versions.last()
But if I copy this code from the console to the behavior it doesn't work. Is there difference between functions of Console and Behaviors?
Also doesn't work function
def versions = versionManager.getVersionsUnreleased(project)
to get all the Unreleased versions and after take a first one.
So, I have two general questions:
1. How to combine both scripts to populate field not with the static one (like "22.1")
2. How to get first (earliest) unreleased version
Thank you in advance, any help will be much appreciated!