I created a script field to display the release date:
<-> import
Issue issue = issue
def fixVersions = issue.fixVersions
//return fixVersions
if (fixVersions) {
def releaseDates = fixVersions.findResults { it.releaseDate }.sort()
//return releaseDates
if (releaseDates) {
String data1 = releaseDates.last().format("dd/MM/yyyy")
DateFormat df1 = new SimpleDateFormat("dd/MM/yyyy")
Date data
data = df1.parse(data1)
return data
}
else {
Date date1 = new Date().parse("dd/MM/yyy", '01/01/9999')
return date1
}
}
else{
Date date1 = new Date().parse("dd/MM/yyy", '01/01/9999')
return date1
}
After reindexing, sorting works well until I change the release date for the release. And sorting doesn't work until I re-index.
how to fix?
Hello @Владислав Яшин
Scripted fields, when they depend on data from outside then the index is not updated unless the issue on which the scripted field is present is modified. This is one of the short-coming of the script field and also explained in the docs
From the docs
It’s worth expanding a little on what I said above. You can only reliably use a calculated field to display a value that is based on the issue’s fields, or subtasks' fields, or linked issues. The reason why is because the value in the Lucene index is only updated when the issue is updated. If you compute some value based on data outside of the current issue, the value in the index may differ from the value displayed on the issue.
https://scriptrunner.adaptavist.com/latest/jira/scripted-fields.html
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.