I am trying to get the date of when an issue first enters In Progres. Pretty standard stuff. Using the base example code from Adaptavist:
package com.onresolve.jira.groovy.test.scriptfields.scripts
import com.atlassian.jira.component.ComponentAccessor
def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def created = changeHistoryManager.getChangeItemsForField(issue, "status").find {
it.toString == "In Progress"
}?.getCreated()
def createdTime = created?.getTime()
createdTime ? new Date(createdTime) : null
The problem is that once I put in that code AND set the Searcher to Date Time Range picker, no one can create any issues in Jira. Specifically, they get this error when creating any Issue Type in any Project:
"We can't create this issue for you right now, it could be due to unsupported content you've entered into one or more of the issue fields. If this situation persists, contact your administrator as they'll be able to access more specific information in the log file."
Log analyzer gives some errors of "Troubleshoot a reindex failure in Jira server" but nothing I could see in that link seemed to apply.
If I create the Scripted Field and set the Template as Date Time it seems to return fine using the Preview function of ScriptRunner (it returns something like 24/Sep/18 2:39 PM), but on the actual issue view, it just gives me an 'Invalid date' error.
If I create the Scripted field and leave the Template as Text Field (multi-line) it returns the correct date, though in a different format (Mon Sep 24 18:39:03 UTC 2018), which is not ideal, but should work in the meantime.
So why when I do it the "correct" way, with the Date Time Picker Template and Date Time Range picker Searcher, does it break Jira?
Note I have NOT tried a full reindex. That takes about an hour on our instance and I haven't been able to schedule that kind of an outage window yet.
Jira Data Center v8.2.5
ScriptRunner v5.6.1.1-jira8