I haven't worked much with scripted fields and the documentation here doesn't seem to talk about returning a Version Picker. Is that a custom field?
Here's what I'm trying to do. I created a custom field called "Planned Fix Version", which I want to script with the following logic:
For this issue, look through the versions for the project it is a part of, and if at the start date of that version, that issue has the FixVersion field set to that version, set Planned Fix Version to that FixVersion. Make sense?
The documentation says that you can "You can either point to a script accessible to jira using an absolute path", so does that mean if I have a JQL query saved I can reference that? I think I know how to do this with JQL, but not groovy.
Worked on this today (goal is to snapshot the planned version at the start of a release), it's a start, but definitely not right yet.
import com.atlassian.jira.component.ComponentAccessor
def projectManager = ComponentAccessor.getProjectManager()
def versionManager = ComponentAccessor.getVersionManager()
def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
// get the history of the fixVersion field for the issue
def changeHistoryForIssueFixVersion = changeHistoryManager.getChangeItemsForField(issue, "FixVersion") //returns List<ChangeItemBean>
// get the project associated with the issue
def issueProject = issue.getProjectObject() //returns type Project
// get the list of versions associated with the project
def projectVersions = versionManager.getVersions(issueProject) //returns List<Version>
// loop through the list of versions
for (version in projectVersions) {
// get the start date for the version
def versionStartDate = version.getStartDate() //returns Date
// look up what the fixVersion was on the start date
for (item in changeHistoryForIssueFixVersion) {
def timeStamp = item.getCreated() // returns TimeStamp
if (timeStamp < versionStartDate ) {
if (item == version){
// if it's the same as the version we are looking at
// return the version we are looking at
return item // TBD, figure out how to have this return a Version
}
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.