I have an event listener on the SprintUpdatedEvent, which I want to use to update all the issues in the sprint having the sprint start and end date to reflect in the fields Target Start and Target End provided by Portfolio.
Since this operation may take a while, I'm starting a new thread to complete this, so the UI won't freeze for the end user until this is completed. I'm aware of the drawback that some users may see incorrect data while browsing issues when this job is running.
What I notice is that I'm running into exceptions updating this field, only when doing it from a new thread. If I update the issue via the Scriptconsole or without a thread (having the UI freeze), no errors / stacktraces are thrown.
When I use self created custom fields of type Date picker it does complete without errors, while running this into a thread.. it makes no sense..
I want to avoid having yet another listener on the IssueUpdatedEvent that when my own custom field is set, it tries to update the Target Start / Target End field..
Thread.start("ScriptRunnerUpdateIssuesInSprint") {
jtlu.preCall()
try {
// retrieving the user here in case it would get lost outside of the thread
ApplicationUser user = userManager.getUserByName("jira-admin")
...
issue.setCustomFieldValue(cfTargetStart, new Date(event.sprint.startDate.getMillis()))
issue.setCustomFieldValue(cfTargetEnd, new Date(event.sprint.endDate.getMillis()))
// another try / catch so it won't stop the thread
...
issueManager.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
} catch(Exception ex) {
log.error ex
} finally {
jtlu.postCall(log)
}
## Stacktrace
[c.o.scriptrunner.runner.ScriptBindingsManager] ## stacktrace [com.google.common.base.Preconditions.checkArgument(Preconditions.java:127), com.atlassian.jira.entity.property.BaseEntityPropertyService.setProperty(BaseEntityPropertyService.java:96), com.atlassian.jira.entity.property.DelegatingEntityPropertyService.setProperty(DelegatingEntityPropertyService.java:41), jdk.internal.reflect.GeneratedMethodAccessor2373.invoke(Unknown Source),
I've tried various ways in updating the field, customField.setValue or using the issueService instead, all with the same result.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.