Hello,
We are on Jira Data Center 8.20.1 and ScriptRunner 6.45.0. We recently upgraded SR after more than 6/8 months.
We have several date picker custom fields that are auto-populated using SR listener. The listener script was using "now" function to populate current date/time on these date fields. When are users use Jira JQL to do filters on these date fields, it worked just fine. Recently, the JQL doesnt seem to find all candidates when filtered based on these date fields.
Here is an example of a JQL that does not pull all relevant Issues -
type = DBCC AND "Deployed in Environment" in (UAT) AND "Actual UAT Deployment Date" >= 2022-03-07 AND status not in (Rejected) ORDER BY "Actual UAT Deployment Date" DESC, key ASC
When I go into these Issues that are missed, to edit the date field and re-pick the same date, now these Issues start showing up in the JQL result.
Here is the SR listener snippet that populates these date fields -
if (("UAT" in selectedValues) && (!(change.getString("oldstring")) || !(change.getString("oldstring").contains("UAT")))) {
def cf1 = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Actual UAT Deployment Date")
def changeHolder1 = new DefaultIssueChangeHolder()
cf1.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(cf1), now),changeHolder1)
def cf2 = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("MT Tag in UAT")
def cf3 = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("MT Deployment Tag")
def changeHolder2 = new DefaultIssueChangeHolder()
cf2.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(cf2), issue.getCustomFieldValue(cf3)),changeHolder2)
def cf4 = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Deployed in UAT By")
def changeHolder4 = new DefaultIssueChangeHolder()
cf4.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(cf4), currentUser),changeHolder4)
}
My Questions -
1) Did anything change recently in newer versions of SR that changed how the "now" function works with Date fields?
2) I need assistance with modifying the script so that going forward these date fields are going to be populated with the correct date/time format?
3) Is there a way to change the above JQL date check ("Actual UAT Deployment Date" >= 2022-03-07) to pull Issues that are currently missed? This will avoid me having to fix active tickets with incorrect date format.
4) If I have to go back and update the date fields manually on all active tickets of type = DBCC, what is the easy way to do this? In Script console, can I do a filter to pull all active DBCCs and then read current date value and replace with the same date/time value? If yes, I would appreciate if I can get help with such a script also.
Thanks much!
Venkat