Custom Fields:
Iteration: Version type Single select field - displays list of all versions for the selected project.
Production Date: Date type
Requirement: Need to populate 'Production Date' with the release date of the version selected in the 'Iteration' field.
Note:
-> We are using a custom field for selecting the version as we want to restrict single version selection on the issue.
-> We cannot take 'Production Date' as a scripted field as we want the date to be input by user in case of a particular version of 'Off Cycle'
We are trying out the Behaviours functionality to achieve the same and are stuck at a point where jira crashes when the behaviour executes.
The below code executes without error and we are getting the selected version from 'Iteration' field in temp.
import com.atlassian.jira.component.ComponentAccessor
def versionManager = ComponentAccessor.getVersionManager()
def versions = versionManager.getVersions(issueContext.projectObject)
def itr = getFieldByName("Iteration")
def prod = getFieldByName("Production Date")
def abc = itr.getValue() as String
def temp = abc.substring(abc.lastIndexOf("[")+1,abc.lastIndexOf("]"))
We now want to read the entire version list (versions) and compare each version name with 'temp' to find the version whose Release date needs to be fetched and put in Production Date.
We appended the below code to see how versions can be read and JIRA crashed.
def xyz = getFieldByName("Test Field") //'Test Field' is a text type field
xyz.setFormValue(versions[0])
Please guide us how this can be achieved. We are thinking of somewhat like below but unable to try out as cannot risk JIRA to be down again.
for(i in versions)
{
def name = i.getName()
if(temp == name && temp !="Off Cycle")
{
def release = i.getReleaseDate()
prod.setFormValue(release)
}
}
We are in the process of JIRA license purchase and the above requirement is critical.
Thanks!